-->
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.  [ 2 posts ] 
Author Message
 Post subject: ObjectDeletedException: deleted object would be re-saved by
PostPosted: Wed Oct 28, 2009 7:25 pm 
Newbie

Joined: Sat Oct 17, 2009 7:34 am
Posts: 9
Hi

I have a parent class(Person) and a child class (UploadedFile)
All updates, inserts work fine but deletes do not. I get this error

i get this error
ObjectDeletedException: deleted object would be re-saved by cascade (remove deleted object from associations)

if this is called
person.getPhotos.remove(0);
and then this is called
session.update(person)

Does the child UploadedFile need to have a person reference as this is what I see on the net?
But is there anyway to avoid this as I think it is over kill
I tried inverse="true" and insvers="false"

Code:
<class name="ie.admin.details.Person" table="PERSON   
        <id name="personID" column="PERSON_ID" type="string">   
          <!-- Chapter 5 of Hibernate Reference PDF for MySQL Auto increment fields -->   
          <generator class="identity"/>   
       </id>   
  ....   
        <list name="photos"   cascade="all-delete-orphan" lazy="false">   
           <!--need update="false" other wise prepared stmt is generated with gym_id twice  -->       
           <key column="person_id"/>   
           <list-index column="file_id"/>     
           <one-to-many class="ie.gymlockr.admin.details.UploadedFile" />   
         </list>   
</class>   
     
     
     
  <class name="ie.gymlockr.admin.details.UploadedFile" table="MEDIA">   
       <id name="file_id" column="FILE_ID" type="string" >   
          <!-- Chapter 5 of Hibernate Reference PDF for MySQL Auto increment fields -->   
          <generator class="identity"/>   
       </id>     
           
       <!--need update="false" and update="false other wise prepared stmt is generated with gym_id twice due to Gym mappings  -->     
       <property name="person_id" column="PERSON_ID" type="string" insert="true" update="false"/>   
           
       <property name="file_type" column="FILE_TYPE" type="int"/>   
       <property name="file_location" column="FILE_LOCATION" type="string"/>   
       <property name="order_num" column="ORDER_NUM" type="int"/>   
       <property name="title" column="TITLE" type="string"/>   
    </class>   


Top
 Profile  
 
 Post subject: Re: ObjectDeletedException: deleted object would be re-saved by
PostPosted: Fri Oct 30, 2009 5:01 am 
Newbie

Joined: Sat Oct 17, 2009 7:34 am
Posts: 9
Cam anyone please advise how to remove a item form a collection in the parent object and presist to the database.

I would prefer if it is unidirectional parent to child.
Please help as I am really stumped?


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