-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Merge and listeners/events
PostPosted: Tue Apr 10, 2007 7:35 am 
Newbie

Joined: Thu Feb 15, 2007 5:46 am
Posts: 12
Location: Helsinki
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]


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 10, 2007 8:40 am 
Newbie

Joined: Thu Feb 15, 2007 5:46 am
Posts: 12
Location: Helsinki
Okay, seems I was using getEntity() from MergeEvent instead of getOriginal(). That seemed to get me a bit further in my agonizing project.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.