-->
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: JPA - Child merge is also updating Parent
PostPosted: Sun Jun 05, 2011 6:14 pm 
Newbie

Joined: Sun Jun 05, 2011 5:59 pm
Posts: 1
Hi,
In my project, we are maintaining the bidirectional relationship between Parent and Child using @OneToMany( mappedBy) in Parent and @ManyToOne in Child class.
Based on the row action property on Parent/Child we call EntityManager.merge() on Parent and Child separately (although both calls may happen in the same transaction).
When we call EntityManager.merge(Parent) by clearing out all the children, it is just saving Parent which is what we need. But when call EntityManager.merge(Child), it is saving Child as well as it is doing a select on the Parent and then doing an update on the Parent record as well. We really don't need the Parent to be updated when we just want to save the Child.
Any suggestions/ideas are greatly appreciated!

thanks


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.