Storing Grails / GORM domain objects in a session - why not?

I am studying Grails / GORM, and as I understand it, the actual practice is not to store domain objects in a session (see http://jira.codehaus.org/browse/GRAILS-978 for a potential fix).

The workaround is simple; just save the link identifier for the domain object in the session, and then retrieve the object using the following query.

My question is: why is it that domain objects cannot be safely stored in a session? I am trying to understand the technical aspects of this.

Thanks!

+4
source share
1 answer

One of my fears is that GORM (I would say Hibernate) uses an open-session-in-view template for every request, where the Hibernate working session will be closed and turn red at the end.

Saving GORM objects in an HTTP session means detaching the object from the previous Hibernate session and reattaching it to the newly created session. This can lead to a conflict between the two versions of the object.

+12
source

All Articles