Hello. Could anybody please recommend me what would be the best practice in my case? 1. My objects contains several one-to-many relationships with other objects, which in turn contain several one-to-many relationships. I do not want to keep an object in memory as a whole, so I use a lazy loading scheme. 2. A user works at a time with different parts of an object, but I want to save changes in the database only once, when the user clicks save. In addition an object or its part can be created from scratch. For this reason I want to detach an object immediately after reading it from the database and to keep in detached until it is time to save changes. However doing this prevents me from loading object branches, when needed (No session Exception). 3. This is a web application with Struts architecture. To make things simple I open Hibernate session just before a call to the action servlet and close it right after. This automatically detaches all read objects. I do not want to automatically reattach them to every new session. I would like to keep the objects detached until the last moment.
Summary. I want to be able to selectively read parts of an object from the database, but to save changes only when I want them to be saved. Thank you, Lev Tannen
|