MyEclipse Forums
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
amir55
Post subject: how to remove asscociations ofa child from father and mother  PostPosted: Nov 12, 2009 - 09:30 PM
Registered Member
Registered Member


Joined: Oct 15, 2005
Posts: 208

hi all

I try to delete an object who has associations with 2 parents I get this error

Exception in thread "main" org.hibernate.ObjectDeletedException: deleted object would be re-saved by cascade (remove deleted object from associations): [bean.Girl#1]


someone told me u need a jar in MyEclipse

the message says remove links but how?

my x,; is as next

1 - father.cfg.xml

<hibernate-mapping package="bean" auto-import="false">
<class name="Husband" table="Husband">

<bag name="children" inverse="true" cascade="save-update, delete" lazy="true">
<key column="father_fk" not-null="false"></key>
<one-to-many class="Child" />
</bag>
</class>
</hibernate-mapping>


1- wife.cfg.xml
<hibernate-mapping package="bean" auto-import="false">
<class name="Wife" table="wife">


<bag name="children" inverse="true" cascade="save-update, delete" lazy="true">
<key column="mother_fk" not-null="false"></key>
<one-to-many class="Child" />
</bag>

</class>
</hibernate-mapping>


I2 - child.cfg.xml

<hibernate-mapping package="bean" auto-import="false">
<class name="Child" table="child">
<many-to-one name="father" class="Husband" column="father_fk" />
<many-to-one name="mother" class="Wife" column="mother_fk" />

I tried to use next fo remove the assciatons but not wotking

Child child = (Child) springDAOManager.findById("bean.Child",1); //ok
System.out.println (child.getName ());

child.getFather().getChildren().remove(child);
child.getMother().getChildren().remove(child);

getHibernateTemplate().delete(child);

anu support please
 
 View user's profile Send private message  
Reply with quote Back to top
support-nipun
Post subject: RE: how to remove asscociations ofa child from father and mo  PostPosted: Nov 16, 2009 - 10:58 AM
Registered Member
Registered Member


Joined: Apr 18, 2007
Posts: 8012

amir55,
What EOD are you referring to?

_________________
Nipun
MyEclipse Support
 
 View user's profile Send private message Send e-mail  
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT - 6 Hours
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Powered by PNphpBB2 © 2003-2004 The PNphpBB Group
Credits