farzad wrote:
.... It doesn't make much difference if you evict objects or select objects to be persisted. These two approaches have the same nature.
Well actually it does matter. In our web application, there are lot of entites that are getting loaded [or assocaited with the session] depending on what is needed on the client. It would be hard for the client side developer to identify what to evict. On the other hand, it is easy for him to say Save/update/delete this object based on the ui actions (and is a simple call to a Manager API).
farzad wrote:
.... if you really know which objects have to make it to db you could evict all objects at the end of the conversation and merge the ones you want to send to db
The problem here is we are in the middle of the conversation and therefore will not be able to evict all the objects in session. Well have to try out a solution where i get hold of all the obejcts in session[just don't know how yet], clear the session, reattach only the one that needs to be persisted, issue the flush, and then reattach all the objects back.
farzad wrote:
...you should consider some read actions in hibernate might cause a flush to database
Using session-per-conversation pattern and setting the Flush mode to Manual.
Using a second session solution is interesting and will try out, hard to guess on how hibernate would behave when trying to update a object in a new session when the original session is still open [ i would cross my fingers on this].
Just to rephrase the the original question i had, may be i can have a clean solution if,
when i issue a session.save(obj) or session.update(obj) ... or any such operation, can we let hibernate know to flush only those entities instead of all the objects in the session?
If not possible, would be very curious to know why it wouldn't be able to do that [kind of hard to think of a reason]?
Thanks a lot for replying.