scesbron wrote:
When you get an instance from a session and don't fetch all its properties, you cannot fetch them after you close the session.
Hibernate does not allow to fetch new data from another session because you then read data from two distinct transaction so you can have stale data.
The best way for you are :
- fetch the set in the first call
- store only the id in the http session and get the camper back in the second call (the second level cache can help you here to avoid another database call)
- use a long session which you connect/disconnect, this is explained in the hibernate in action book, maybe you can find an example in the caveat emptor app
(JBoss 4.0.2 comes with Hibernate 3)
This information isn't entirely correct. Read section
11.6 Modifying detatched Objects in of the Hibernate 3.0.5 reference doc.
If your Camper object hasn't been modified yet you can use session.lock() to reassociate it with the new session.