This will be of no interest to you unless you do Hibernate coding.
Let’s say I have an Object, Foo. Foo remains within tomcat’s session object.
I DO NOT want a Hibernate session to stay open with Foo. I *do* want a Hibernate session to open and close at specific times about the object, but I want the object to detach otherwise.
Here is an example with a User object. This is what I *want* to happen.
1) User logs in.
1a) Hibernate does the lookup user by name thing, finds a User object (u), creates it.
1b) User object (u) is returned. Hibernate session associated with that User object (u) is closed. User object (u) is now detached.
2) User changes his email address. Clicks “save changes”. This changes a field on the User object (u).
2a) Hibernate opens a Session and does a save on the User object (u).
2b) Hibernate session associated with that User object (u) is closed. User object (u) is now detached. (again).
Basically what I’m trying to do is to grab objects and hold them in ram *WITHOUT* keeping a database connection open.
The docs do not really explain how to do this – to disconnect an Object from its associated Hibernate Session.
Code snippets would be appreciated.