-->
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: cascading problems on composite-element
PostPosted: Fri May 19, 2006 8:01 am 
Newbie

Joined: Tue Jan 24, 2006 12:04 pm
Posts: 12
Hi,

Shop has a set of contacts. it is the many to many relationship.
i added an rel_obj_contact as relationtable which contains objid(shopid), contactid and relationtypeid.
ObjectContact is a compositeElement wrapping 1 contact and 1 relationtype.

The PROBLEM is, if i delete a shop, the relationship item in rel_obj_contact will not be deleted. (i want the relationship in my database deleted)

How can I implement it?


Code:
<Shop...>
      <set name="shopContacts"
             table="REL_OBJ_CONTACT"
             cascade="all"
          lazy="false">

         <key column="OBJID"/>

           <composite-element class="ObjectContact">
              
            <many-to-one name="contact"
                      column="contactid"
                      class="Contact"
                      cascade="save-update"/>
                     

            <many-to-one name="relationType"
                      column="relationid"
                       not-found="ignore"
                      class="RelationType"
                      cascade="save-update"/>

          </composite-element>
          
       </set>
...
</Shop>


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 19, 2006 11:13 am 
Newbie

Joined: Tue Jan 24, 2006 12:04 pm
Posts: 12
Does anyone know the reason?

many thanx in advance!


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 02, 2006 9:24 pm 
Beginner
Beginner

Joined: Thu Oct 06, 2005 8:14 pm
Posts: 23
did you get an answer for this
I seem to be facing the same issue
Thanks
Subu


Top
 Profile  
 
 Post subject: Re: cascading problems on composite-element
PostPosted: Tue Oct 03, 2006 6:21 am 
Newbie

Joined: Mon Sep 13, 2004 9:44 am
Posts: 13
Your mapping looks okay, so there may be a problem with the code. Are you modifying a Shop entity that you obtained from the current Session?

Note that this has nothing to do with cascades. The deletion of an item in the join table REL_OBJ_CONTACT is done when Hibernate does a Session.flush() and it notices that the collection has changed. This works because Hibernate replaces the original Set with its own Set implementation which tracks changes. It does this replacement when the entity is saved or when it constructs a new instance from query results.


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.