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.  [ 4 posts ] 
Author Message
 Post subject: org.hibernate.ObjectDeletedException:
PostPosted: Fri May 13, 2005 6:53 am 
Newbie

Joined: Fri Mar 18, 2005 1:05 pm
Posts: 8
Location: Delhi
Version 3

Hi I have 2 classes sharing parent child relation.
Cascade option in parent is set to "save update"

While deleting parent

I am getting all children ...deleting them one by one

and then deleting the parent.

While doin this it gives me exception

org.hibernate.ObjectDeletedException: deleted object would be re-saved by cascade (remove deleted object from associations): [com.tpgmail.spp.model.MachineAssignment#1]:deleted object would be re-saved by cascade (remove deleted object from associations):[com.tpgmail.spp.model.MachineAssignment#1]

Can any one help this is really urgent.

Thanks in advance


Top
 Profile  
 
 Post subject: Re: org.hibernate.ObjectDeletedException:
PostPosted: Fri May 13, 2005 6:54 am 
Expert
Expert

Joined: Mon Feb 14, 2005 12:32 pm
Posts: 609
Location: Atlanta, GA - USA
sunilkumarsh wrote:
Version 3

Hi I have 2 classes sharing parent child relation.
Cascade option in parent is set to "save update"

While deleting parent

I am getting all children ...deleting them one by one

and then deleting the parent.

While doin this it gives me exception

org.hibernate.ObjectDeletedException: deleted object would be re-saved by cascade (remove deleted object from associations): [com.tpgmail.spp.model.MachineAssignment#1]:deleted object would be re-saved by cascade (remove deleted object from associations):[com.tpgmail.spp.model.MachineAssignment#1]

Can any one help this is really urgent.

Thanks in advance


You really need to include your mapping files and code for anyone to be able to help you with more than just guesses.


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 13, 2005 7:00 am 
Newbie

Joined: Fri Mar 18, 2005 1:05 pm
Posts: 8
Location: Delhi
hey thanks for replying so fast but be very gratefull if get working answer from u

I am copying the mapping file

this is parent in which child is mapped

<!-- Children -->
<set name="machineAssignments" inverse="true" cascade="save-update">
<!-- Meta data -->
<meta attribute="scope-set">private</meta>
<meta attribute="gen-one-to-many">true</meta>
<meta attribute="default-value">new HashSet()</meta>

<key column="prc_id"/>
<one-to-many class="com.tpgmail.spp.model.MachineAssignment"/>
</set>

This is child in which parent is mapped
<!-- Parents -->
<many-to-one name="sortingList"
class="com.tpgmail.spp.model.SortingList"
cascade="none"
outer-join="auto"
column="run_id"
foreign-key="spp_mas_run_fk"
index="spp_mas_run_fk_ind"
not-null="true" />

<many-to-one name="productionCapacity"
class="com.tpgmail.spp.model.ProductionCapacity"
cascade="none"
outer-join="auto"
column="prc_id"
foreign-key="spp_mas_prc_fk"
index="spp_mas_prc_fk_ind"
not-null="true" />

Now we have made 2 method
first to get the child this will return the list of child ID.
I will put this in loop ..load the id and delete it.

After this we will load the parent and simply delete it.
Thats it.
But unfortunately its giving me error
:(


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 13, 2005 8:30 am 
Expert
Expert

Joined: Mon Feb 14, 2005 12:32 pm
Posts: 609
Location: Atlanta, GA - USA
sunilkumarsh wrote:
hey thanks for replying so fast but be very gratefull if get working answer from u

I am copying the mapping file

this is parent in which child is mapped

<!-- Children -->
<set name="machineAssignments" inverse="true" cascade="save-update">
<!-- Meta data -->
<meta attribute="scope-set">private</meta>
<meta attribute="gen-one-to-many">true</meta>
<meta attribute="default-value">new HashSet()</meta>

<key column="prc_id"/>
<one-to-many class="com.tpgmail.spp.model.MachineAssignment"/>
</set>

This is child in which parent is mapped
<!-- Parents -->
<many-to-one name="sortingList"
class="com.tpgmail.spp.model.SortingList"
cascade="none"
outer-join="auto"
column="run_id"
foreign-key="spp_mas_run_fk"
index="spp_mas_run_fk_ind"
not-null="true" />

<many-to-one name="productionCapacity"
class="com.tpgmail.spp.model.ProductionCapacity"
cascade="none"
outer-join="auto"
column="prc_id"
foreign-key="spp_mas_prc_fk"
index="spp_mas_prc_fk_ind"
not-null="true" />

Now we have made 2 method
first to get the child this will return the list of child ID.
I will put this in loop ..load the id and delete it.

After this we will load the parent and simply delete it.
Thats it.
But unfortunately its giving me error
:(


I'd really like to help you here but there's a reason they post this at the top.
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:

Mapping documents:

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Name and version of the database you are using:

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.