MyEclipse: how to remove asscociations ofa child from father and mother

amir55 - Nov 12, 2009 - 09:30 PM
Post subject: how to remove asscociations ofa child from father and mother
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
support-nipun - Nov 16, 2009 - 10:58 AM
Post subject: RE: how to remove asscociations ofa child from father and mo
amir55,
What EOD are you referring to?
All times are GMT - 6 Hours
Powered by PNphpBB2 © 2003-2004 The PNphpBB Group
Credits