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: Delete-orphan inside component
PostPosted: Tue Aug 28, 2012 2:14 pm 
Newbie

Joined: Thu Jun 17, 2010 10:41 am
Posts: 3
Hi,

I mapped a class as a component so it gets deleted whenever the parent (MyClass) is deleted (see mapping below). So far this works.

The component itself contains a collection of objects (the bag).

Code:
<class name="MyClass">
      ...
        <component
            name="myComponent"
            access="field"
            insert="true"
            update="true"
            lazy="false">

            <bag
                    name="something"
                    access="field"
                    lazy="false"
                    cascade="all-delete-orphan">
                <key column="MyClass_id" />
                <one-to-many class="Something" />
            </bag>
        </component>
</class>


Whenever I delete a MyClass object, the component is removed and the collection as well. Exactly what I wanted!

Now what doesn't work is the following:

Code:
MyClass myObject; // comes from the database
myObject.setMyComponent(someNewComponent); // set new component with a new something collection
saveOrUpdate(myObject); // Throws A collection with cascade="all-delete-orphan" was no longer referenced by the owning entity instance


Is there a way to get this collection deleted? If not, that means I can never replace the component with a new instance. If that is the case, is there an alternative mapping for this situation?

Thanks!
Bert.


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.