cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Gentry <blackn...@gmail.com>
Subject Re: removeToManyTarget and delete from ObjectContext
Date Wed, 22 Jun 2016 13:50:12 GMT
Hi Lon,

Removing an object doesn't do a delete.  You also have to do a
context.deleteObject(..) if you want to delete it.  The reason is so that
you can do something like this:

order = // some existing order
order.removeFromUnfilledItems(item);
order.addToFilledItems(item);
context.commitChanges();

This allows you to shuffle objects around to different relationships, which
will update the foreign keys (as you've seen).

If you are wanting cascade deletes (or a few other delete actions), don't
look at the "To Dep PK" setting in DbEntity Relationships (which happens on
insert/new objects), look at "Delete Rule" in the ObjEntity Relationships
settings.  These delete rules are used when you actually do a
context.deleteObject(..) and context.commitChanges().

mrg


On Tue, Jun 21, 2016 at 9:27 PM, Lon Varscsak <lon.varscsak@gmail.com>
wrote:

> Does removeToManyTarget cause the object to be deleted from the context if
> the “to dep key” box is checked from the master->detail? I’m removing a
> detail object where this configuration is set, but it’s triggering an
> update and not a delete.
>
> Thanks,
>
> Lon
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message