cayenne-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrus Adamchik <and...@objectstyle.org>
Subject Re: setter for toMany in generated classes
Date Mon, 26 Jan 2015 21:23:40 GMT

> On Jan 26, 2015, at 1:47 PM, Johannes <jotpe.osm@gmail.com> wrote:

> My motivation for introducing the delete parameter was, that your are
> not able to the treat orphaned objects with a delete rule. Please
> correct me, if its wrong. The delete rule is called only, if you trigger
> .delete(). If you just remove your relationship: no entity will be
> deleted. I guess this is the deletion question Michael Gentry was
> talking about.

Good point about delete rules. You are absolutely right and I stand corrected. Perhaps one
other way to deal with deletions, is to return a collection of removed objects from the method,
leaving it up to the caller to deal with them:

// sync...
List<? extends DataObject> removed = o.setToManyTarget(Artist.PAINTINGS.getName(), newPaintings,
true); 

// delete ... or not
// o.getObjectContext().deleteObjects(removed); 

Andrus






Mime
View raw message