-->
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.  [ 1 post ] 
Author Message
 Post subject: One-To-Many - Cascade problem
PostPosted: Mon Jun 29, 2009 2:01 pm 
Newbie

Joined: Mon Jun 29, 2009 1:45 pm
Posts: 3
i have an object with a list of references to different concrete implementations of an abstract base class. when i try to remove a reference from the collection and saveOrUpdate() the object, the operation isn't cascaded and the referenced object isn't removed from the database. The referenced objects are ONLY removed if i remove all refernces from the list, but just one, doesn't work.

Mapping:

Code:

<composite-id access="property">
  <key-property name="key1" column="key_col1"/>
  <key-property name="key2" column="key_col2"/>
</composite-id>

<list name="values"
          lazy="false"
          cascade="save-update,delete,delete-orphan">
  <key not-null="true">
    <column name="key_col1"/>
    <column name="key_col2"/>
  </key>
  <list-index base="0" column="pos"/>
  <one-to-many class="AbstractAttributeValueObject"/>
</list>


Here, AbstractAttributeValueObject is the abstract base class. There exists several implementations mapped as <subclass> using the Table per Class Hiearchy - strategy.

What do i have to do so that the remove operation is cascaded and the refernced object is deleted from the database?

Right now i perform the following steps:

    0. obtain session
    1. load object
    2. detach object, put it into user session
    3. remove references from list
    4. call saveOrUpdate() on a different hibernate session


chris


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.