Hello,
I have a problem concerning merging. What I need to do, is do a copy-on-save functionality at every modification. I do this by loading the latest object graph and comparing it with the modified version, marking dirty (nulling the ID) all modified objects in the persistent version. Then doing a saveOrUpdate for the persistent version, which saves the modified objects as new database rows. Then I merge the modified object graph on the original (keeps the ID intact, providing some referential integrity).
My problem is that when I merge, I need to update the modified objects' timestamp.
First I tried with an Interceptor and the onFlushDirty method, but that doesn't seem to be called when merging. Then I tried with a MergeEventListener, but even though I set the object's timestamp to current time, it's not getting persisted to database.
Is there a way I can get the timestamp to be updated at merging?
I need to set the timestamp once at insert, when I insert the "original" row in the database and then in any updates. But not for the extra version rows that are created at copy-on-write. Sort of like if there were a generated="update" (instead of never, insert, always).
I would really appreciate any insight.
Thanks,
Jussi
Hibernate version:3.1[/b]
|