cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Gentry <mgen...@masslight.net>
Subject Re: Question about removing detail records under a master record (master object with detail objects!)
Date Wed, 25 May 2011 20:04:00 GMT
Hi Tony,

Calling:

    event.removeFromEventmenuArray(obj); context.commitChanges();

unlinks the record (which you are seeing with the null FK), but does
not delete it (after all, you may be adding the object to a different
relationship).

Try doing a context.deleteObject(obj) before committing.

mrg


On Wed, May 25, 2011 at 3:54 PM, Tony Dahbura <dahbuan@aopslab.com> wrote:
> I have an object called event that contains eventMenu as an array of objects. event is
a table in my database and eventMenu is a table. Each of the objects are working fine for
inserts and queries...
>
> However if I want to delete an eventitem I tried calling event.removeFromEventmenuArray(obj).
Then calling context.commitChanges();
>
> What happens is the Cayenne marks the fkey in eventMenu as null instead of deleting the
eventMenu row from the database. I have tried all the possible delete rules (I tried cascade,
tried no action, all of them). I cannot get the ORM to delete the row from the detail record.
>
> All the foreign key records are setup correctly and if I delete the event it cascade
deletes the eventMenu rows as I want.
>
> Any ideas, if I try to delete the eventMenu manually this works okay, but it seems to
me the event object should respect the remove operation and do this upon a commit?
>
> Am I misunderstanding how to do this?
>
> Thanks,
> Tony
>
>

Mime
View raw message