I have an application which allows the user to edit a record over a long period of time. The record should not be saved to the database until a save button is clicked. Detached objects sounded perfect, but I have a problem. In various sessions after the one in which the record being edited was loaded I need to query/load other objects which may directly or indirectly link back to the record being edited, or visa-versa. If I don't re-associate the record, I end up with two different java objects, and hence an error when the user finally tries to save the record. If I DO re-associate the record (using session.lock(obj,LockMode.NONE)) it complains that the object is dirty. Is there a sensible way round this?
Ideally, I would also like to be able to "refresh" these linked-but-not-being-edited objects from the database, but the hibernate documentation says that the refresh method should not be used to implement long application transactions (but gives no reason). Why is this?
Any pointers in the right direction would be much appreciated. Oh, and I'm using Hibernate 3
|