-->
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: Dereference a collection with cascade="all-delete-orpha
PostPosted: Tue Sep 28, 2004 9:04 pm 
Newbie

Joined: Fri Jun 11, 2004 4:58 pm
Posts: 9
Hibernate version: 2.1.6

We're using hibernate to persist an entity with the following mapping:

Code:
<hibernate-mapping>
    <class name="com.mycompany.Project" table="Projects">
        <id name="id" column="id" type="java.lang.Long">
            <generator class="increment"/>
        </id>
        <many-to-one name="defaultView" class="com.mycompany.View" column="DefaultViewId"/>
        <property name="projectId" type="java.lang.Long" column="ProjectId"/>
        <list name="views" table="ProjectViews" cascade="all-delete-orphan">
            <key column="ProjectId"/>
            <index column="ViewSequence"/>
            <many-to-many class="com.mycompany.View" column="ViewId"/>
        </list>
    </class>
</hibernate-mapping>


During normal application operation, instances of the Project object are obtained from Hibernate, then serialized and sent to a client application where they are deserialized, viewed/changed, reserialized, and sent back to the server application for storage via Hibernate.

On the client side, the Project's list of Views list may be replaced by a new ArrayList of Views.

When a Project is retrieved from Hibernate, sent to the client app, and returned to Hibernate we receive the exception:

You may not dereference a collection with cascade="all-delete-orphan"

To me this means that since we're mapping a Project's Views as cascade all-delete-orphan, Hibernate expects certain behavior with respect to that collection. Can someone help me understand why we're getting this exception and how we can circumvent it? Is our only option to use a different cascade strategy and manually delete the orphaned Project Views?

Thanks!
-Alex


Top
 Profile  
 
 Post subject: Re: Dereference a collection with cascade="all-delete-o
PostPosted: Tue Nov 02, 2004 10:19 pm 
Newbie

Joined: Sat Aug 07, 2004 8:03 pm
Posts: 2
Location: Porto Alegre - RS - Brazil
alexkwolfe wrote:

Can someone help me understand why we're getting this exception and how we can circumvent it?
Thanks!
-Alex



I think that if you use something like project.getViews().clear() to delete the childs will work...

I'm a newbie... So, I just think... try it. :)

Denis


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.