Regular |
|
Joined: Mon Jul 26, 2004 2:28 pm Posts: 86 Location: Pensacola, Florida
|
You could open a new (different) session and perform a session.get( ) or session.load( ) on the object using the class and primary key value to load the current persisted state of the object. You could also set the flush mode of the current session to FlushMode.COMMIT or FlushMode.NONE to allow dirty reads before performing the session.get( ) or session.load( ).
You can then do a comparison once you have loaded the old state.
I don't think that you can call the dynamic update API through the interfaces...you would have to cast the session to a SessionImpl, and even then the fields might be private. Take a look at the source code...
I wouldn't try any of these approaches unless you have a *very* compelling reason to look at the old state, and if that were the case, a Memento pattern implementation for your POJOs might be a better solution. Keep in mind that Hibernate manages a lot of stuff, and anything you try to manage in your code will possibly be in conflict with Hibernate and may have unpredictable (or at least undefined) results.
- Jesse
|
|