mstein / elasticsearch-grails-plugin

ElasticSearch grails plugin
Based on Graeme Rocher initial stub. Note that it is still in early stage.
Other
62 stars 164 forks source link

Hibernate session's flushMode set to FlushMode.MANUAL unexpectedly #46

Open olisikh opened 11 years ago

olisikh commented 11 years ago

Hi, guys.

Nice plugin, very useful, thank you for it!

I had taken a look at #15 issue, and was happy to see that some issues with hibernate sessions were resolved, but it seems not all of them.

I have elasticsearch-grails-plugin up-to-date taken from your repo. When I try to save any item to database and then to remove it via my "admin UI", an exception is thrown after calling delete operation. Here's the message:

  Message: Write operations are not allowed in read-only mode (FlushMode.MANUAL): 
  Turn your    Session into flushMode.COMMIT/AUTO or remove 'readOnly' 
  marker from transaction definition.

This error is thrown only when plugin is enabled. As a workaround, which prevents this weird exception:

  Domain.withTransaction {
      domain.delete(flush: true)
  }

But it's not pretty, is it? Appreciate any help! Is it a hibernate bug, or another plugin's session management bug?

dongwq commented 11 years ago

this is a weird phenomena. I use a Filter to set each session.setFlushMode(FlushMode.AUTO).

or do sessin.flush in filter' afterView closure.