-->
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: Bidirectional Cascade issue
PostPosted: Thu Sep 30, 2010 11:30 am 
Newbie

Joined: Wed Sep 29, 2010 12:54 pm
Posts: 2
If I have a parent/child relationship, is there a way to modify the parent and the child, but then only save the child's changes? I am currently trying this, but the save when called on the child still does a save on the parent as well.

Parent contains:
Code:
@OneToOne(mappedBy="parent",cascade=CascadeType.REMOVE,orphanRemoval=true)
private Child child;


Child contains:
Code:
@OneToOne
@JoinColumn(name="ParentID")
private Parent parent;


Code that doesn't work as intended:
Code:
Parent p = pDAO.getAll().get(0);
Child c = p.getChild();
c.setName("NEW NAME " + Calendar.getInstance().getTime());
p.setName("A NEW NAME " + Calendar.getInstance().getTime());
cDAO.save(c);


Is what I am trying to do possible by modifying my mappings?

Thanks,
Adam


Top
 Profile  
 
 Post subject: Re: Bidirectional Cascade issue
PostPosted: Fri Oct 01, 2010 8:09 am 
Newbie

Joined: Tue Feb 02, 2010 10:37 am
Posts: 13
inverse="true" should be applied on the association of parent entity.


Top
 Profile  
 
 Post subject: Re: Bidirectional Cascade issue
PostPosted: Fri Oct 01, 2010 8:20 am 
Newbie

Joined: Wed Sep 29, 2010 12:54 pm
Posts: 2
Isn't the mappedBy clause in the parent side annotations doing just that?


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.