-->
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: Need Help! deleted object would be re-saved by cascade
PostPosted: Fri Sep 05, 2008 12:49 pm 
Newbie

Joined: Fri Sep 05, 2008 12:09 pm
Posts: 1
I am trying to delete an entity that has a self reference to itself and i get the following error. I am using hibernate 3 and this functionality was working well in the older version of hibernate 2



deleted object would be re-saved by cascade (remove deleted object from associations): [com.entity.ReferralEntity#5911]
at org.apache.struts.action.RequestProcessor.processException(RequestProcessor.java:523)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:421)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
at com.iso.scm.util.HibernateRequestProcessor.process(HibernateRequestProcessor.java:55)


Table Mapping

1) ObjectA - Maps to TableA
2) ObjectB - Maps to TableB

Class structure

Code:
public class ObjectA
{
    private ObjectB objB;     
}

public class ObjectB
{
    private List objB1;     // List contains object of type ObjectB
    private List objB2;     // List contains object of type ObjectB
}


Hibernate Mapping for OjectB

Code:

<list name="objB1" table="TableB" fetch="join" cascade="all" lazy="false" where="C_ENTY_TYP = '0003'">
   <key column="I_PRNT_CASE_ENTY"/>
     <list-index column="I_REFR_ENTY"/> --- The key which link it ObjectA
       <one-to-many class="ObjectB" />
</list>

<bag name="objB2" where="C_ENTY_TYP = '0002'"  table="TableB"   fetch="join" cascade="all" lazy="false">
   <key>
      <column name="I_PRNT_CASE_ENTY"/>
       </key>
   <one-to-many class="ObjectB" />
</bag>




Quote:
When i delete(objectA) i.e deleteing ObjectA, i expect all the child objects (ObjectB) to get deleted as well, but instead i get the above error. I did search a bit and tried removing objB from ObjectA but that would leave the child Objects of objB,B1,B2 as it is. Please let me know as to how i can achieve the above scenario. I am struggling with this for a while...i almost gave up and looking up for someone to guide me.


Thanks in Advance!!!
Zieus


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 09, 2008 7:45 pm 
Expert
Expert

Joined: Tue May 13, 2008 3:42 pm
Posts: 919
Location: Toronto & Ajax Ontario www.hibernatemadeeasy.com
Wouldn't it be just as simple as making sure the self-reference is deleted anywhere the object is maintained by the Hibernate session?

_________________
Cameron McKenzie - Author of "Hibernate Made Easy" and "What is WebSphere?"
http://www.TheBookOnHibernate.com Check out my 'easy to follow' Hibernate & JPA Tutorials


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.