(1) would seem to only work for new objects, not ones that just need updating (you can't really update an object that has a null id, obviously). That would also be helpful for an application I'm working on too; its workflow is like so:
1. User loads the page, with a Hibernate session created and subsequently closed to read in all the data objects
2. User modifies the data on the page
3. User click save, with a Hibernate session created that calls update(...) on every data object
Obviously that becomes very inefficient the more data objects there are. I could have two separate lists of data objects, ones that haven't been modified and ones that have, but that just seems very clunky; there has to be a better way. If I have a single session persistent through the entire "conversation" and just use multiple transactions, would that allow me to skip the update step (when I want to save, I just start a transaction, call session.flush, and then commit)? I've read through the documentation and the articles on the website, but I haven't found anything yet that specifically states whether or not Hibernate keeps track of object changes in-between transactions on a single session.
|