-->
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: org.hibernate.ObjectDeletedException When deleting child obj
PostPosted: Tue Mar 21, 2006 6:02 am 
Newbie

Joined: Fri Jul 15, 2005 12:42 am
Posts: 18
Hi
I have a bidirectional mapping implemented.
I am getting a child object and then explicitly deleting it i am getting an eception org.hibernate.ObjectDeletedException Please help
Thanks in advance

Hibernate version:3.0.5

Mapping documents:
<class name="Person">
<id name="id" column="personId">
<generator class="native"/>
</id>
<set name="addresses"
table="Address"
lazy="false"
inverse="true"
cascade="all-delete-orphan">
<key column="personId"/>
<one-to-many column="addressId"
class="Address"/>
</set>
</class>

<class name="Address">
<id name="id" column="addressId">
<generator class="native"/>
</id>

<many-to-one name="person"
column="personId"
class = "Person"
cascade = "none"
not-null="true"/>
</class>


Code between sessionFactory.openSession() and session.close():
address = (Address) session.get(Address.class, id);
.
.
.
session.delete(address);


Full stack trace of any exception that occurs:
org.hibernate.ObjectDeletedException: deleted object would be re-saved by cascade (remove deleted object from associations): [com.transaxiom.axslogistics.fincalculation.dto.DecisionLineChargeDTO#1442]
at org.hibernate.impl.SessionImpl.forceFlush(SessionImpl.java:742)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:166)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:96)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:69)
at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:468)
at org.hibernate.engine.Cascades$5.cascade(Cascades.java:154)
at org.hibernate.engine.Cascades.cascadeAssociation(Cascades.java:771)
at org.hibernate.engine.Cascades.cascade(Cascades.java:720)
at org.hibernate.engine.Cascades.cascadeCollection(Cascades.java:895)
at org.hibernate.engine.Cascades.cascadeAssociation(Cascades.java:792)
at org.hibernate.engine.Cascades.cascade(Cascades.java:720)
at org.hibernate.engine.Cascades.cascade(Cascades.java:847)
at org.hibernate.event.def.AbstractFlushingEventListener.cascadeOnFlush(AbstractFlushingEventListener.java:121)
at org.hibernate.event.def.AbstractFlushingEventListener.prepareEntityFlushes(AbstractFlushingEventListener.java:112)
at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:59)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:26)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:730)


Name and version of the database you are using: Oracle 9i


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 21, 2006 8:02 am 
Regular
Regular

Joined: Tue Jan 03, 2006 9:52 am
Posts: 52
Location: Zurich
Try this:
address.getPerson().remove(address);
session.delete(address);
Urs


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 21, 2006 8:07 am 
Newbie

Joined: Fri Jul 15, 2005 12:42 am
Posts: 18
Already tried that but same result i even tried nullifying person in the address bean still no afftect


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.