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 <dahb...@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
>
>

Reply via email to