Hi,
I'm trying to implement object history tracking using the Event handlers, as suggested by Christian to be a replacement for the "old" interceptor way.
The idea is to implement a PreUpdateEventListener that creates a "backup" of the old object state before doing the actual update. The easiest approach is to use the "oldState" fields, supplied by the PreUpdateEvent to create this "historical" new entry and this actually works.
However, when you use detached objects, the oldState of the object isn't available! This is logical in a way, but breaks the approach above.
What would be the best approach to actually read the "old" values in the database, without coming into conflict with the cache or overwriting the updates that have been made to the object? I've tried several approaches, but a lot of it runs into "possible nonthreadsafe access to session" errors or similar. It just doesn't seem possible to get the old state of an object after it has been modified.
Please help!
(Hibernate 3.0 RC1)
|