-->
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.  [ 3 posts ] 
Author Message
 Post subject: Update of an object containing Sets of objects.
PostPosted: Thu Sep 04, 2003 8:22 am 
Beginner
Beginner

Joined: Wed Aug 27, 2003 5:03 am
Posts: 34
When i, do an update of my parent object containing sets with child objects, i get this error: " You may not dereference a collection with cascade="all-delete-orphan" ".

Insert and delete of the objects goes fine, but updating gives this error. Anyone knows what i'm doing wrong?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 04, 2003 10:55 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
You can't change a collection reference when the collection is mapped with cascade="all-delete-orphan".


Just make sure your getter returns the same collection instance and this exception will not occur.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 14, 2003 3:28 pm 
Newbie

Joined: Tue Oct 14, 2003 3:05 pm
Posts: 4
That is a little easier said than done.

It is our practice to always make a copy of a collection passed in from a setter or out through a getter. I don't have TOO much of a problem doing this for the setter, since our setters for collections are private (only exist for the persistence implementation). But I have a hard time passing the same instance out of a getter that we are refering to in our class. Someone could modify the contents, I have to make sure the collection is thread safe, etc... I am curious to know why I can't change the reference, if I'm just copying the data. I can't think of a good reason why hibernate would need to refer to the same instance, but I'm sure you have one. Could you suggest a workaround (i.e. create an immutable implementation of List and pass that to Hibernate; how would hibernate create an instance of that collection on retrieve.). Otherwise, I suppose we'll have to explictly delete orphaned objects. Thanks.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.