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.  [ 3 posts ] 
Author Message
 Post subject: Clarification Needed For saveOrUpdateCopy
PostPosted: Fri Aug 20, 2004 4:16 pm 
Newbie

Joined: Tue Sep 02, 2003 8:22 am
Posts: 19
Location: Chicago
I'm using Hibernate 2.1.6, and trying to maintain an audit trail for an object. The object is called Person, and it has a many-to-one association to Address (cascade all, unidirectional).

The webapp lifecycle for this process follows:


1) Retrieve the object from the database, convert to a form object.
2) Send to the user; user submit changes.
3) Load the original object from the database to track the changes made to the object by the user. The form properties are copied to the object retrieved. (An interceptor handles the onFlushDirty call.)
4) Save the updated Person object with saveOrUpdateCopy(Object).

When I save the object, I get a NonUniqueObjectException because the Address instance is already associated with the Session. The saveOrUpdateCopy call doesn't seem to cascade calls with saveOrUpdateCopy, but with saveOrUpdate. How can I get around this NUOE problem?

Ideally, there is a generic way to handle this, since I want to audit most of the objects in my domain model. Any help is appreciated. I've searched the forum, but most of the responses are pretty terse.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 20, 2004 7:20 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Quote:
The saveOrUpdateCopy call doesn't seem to cascade calls with saveOrUpdateCopy, but with saveOrUpdate.


Yes, this is really a bug in the current implementation of saveOrUpdateCopy(). Its one that will get fixed soon.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 20, 2004 7:31 pm 
Newbie

Joined: Tue Sep 02, 2003 8:22 am
Posts: 19
Location: Chicago
Can you suggest a short-term workaround, or some hints as to the patch required? I'm familiar with the source and would happily work on it.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.