-->
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.  [ 1 post ] 
Author Message
 Post subject: merging vs. persisting and reattaching to PersistenceContext
PostPosted: Thu Jan 22, 2009 4:20 pm 
Newbie

Joined: Thu May 01, 2008 8:38 pm
Posts: 2
So, as outlined in :

Automatic State Detection

I understand that during a merge, the given instance is not reattached to the persistence context, but is instead returned by the merge operation. In the context of an update to an existing entity rather than persisting a new entity, I can understand this rational.

However, one point in the documentation discussed here:

Transitive persistence

says that cascading on ManyToOne/ManyToMany relationship doesn't really make sense, however it is acceptable to say, cascade merges and persists only to save yourself some typing.

In my case, I have objects with ManyToOne relationships. In the event that the parent object is a new object, the ManyToOne relationships may or may not already exist, thus I need the insert-or-update semantics of merge rather than persist. What bothers me is the semantics of adding a new entity and having to return the result from the merge operation (so that I have autogenerated id's and such).

I understand why this is necessary, but I'm wondering if there is a way to reattach the given instance to the persistence context during a merge (i.e. how persist works) without having to return the object returned by merge().

Any thoughts??

Thanks in advance!
Justin[/url]


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

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.