cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrus Adamchik <and...@objectstyle.org>
Subject Re: deleting tomany objects
Date Wed, 21 Oct 2009 08:07:31 GMT
Hi Mark,

> However in the modeler the delete rule for both sides of the  
> relationship is "No Action".

you may want to change delete rule to "Nullify" from many side to one  
side of the relationship. Otherwise you'd have to explicitly unset the  
relationship before deleting an object.

Andrus

On Oct 21, 2009, at 10:37 AM, Mark Fraser wrote:

> Hello,
>
> I am using Cayenned 2.0.4.
>
> What is the proper way to delete the full collection of tomany  
> objects and have the target object's array correctly reflect the  
> deletion?
>
> The manual (http://cayenne.apache.org/doc20/deleting-objects.html)   
> says to use dataContext.deleteObjects if you want to delete all  
> objects in the collection.
> What it does not say is that the target object's array will still  
> contain references to objects that are scheduled for deletion (or  
> have been deleted after committal).
>
> I have code like this:
>
> System.out.println("paintings: " +  
> artist.getPaintingsArray().size());  // "1"
> dataContext.deleteObjects(artist.getPaintingsArray());
> System.out.println("paintings: " +  
> artist.getPaintingsArray().size());  // "1"
> dataContext.commitChanges();
> System.out.println("paintings: " +  
> artist.getPaintingsArray().size()); // "1"
>
>
> But if I try to delete the objects myself using an iterator as  
> described on that manual page I get a  
> ConcurrencyModificationException--which is warned about on that  
> page.  It says this may result from the object being deleted having  
> a "nullify delete rule".  However in the modeler the delete rule for  
> both sides of the relationship is "No Action".
>
> I would appreciate if someone could suggest how I am supposed to do  
> this (without switching Cayenne versions).
>
> Thanks,
>
> Mark
>
>
>
>
>
>


Mime
View raw message