Hi Tony,

Yes, you need to unlink the object from the relationship and also delete it.

mrg


On Tue, May 31, 2011 at 11:39 AM, Tony Dahbura <dahb...@aopslab.com> wrote:
> Michael:
> I see this now, but when calling the context.deleteObject(obj) the 
> eventMenuArray continues to say there are two elements there-although there 
> should only be one after the delete.
>
> I even tried re-reading the master record back.  The database shows only one 
> detail so the delete did work-why is the relational array showing the 
> incorrect number?
>
> Do I need to call both event.removeFromEventmenuArray(obj) and 
> context.deleteObject(obj) then a commit?
>
> Thanks,
> Tony
>
>
> ----- Original Message -----
> From: "Michael Gentry" <mgen...@masslight.net>
> To: user@cayenne.apache.org, "Tony Dahbura" <t...@aopslab.com>
> Sent: Wednesday, May 25, 2011 4:04:00 PM
> Subject: Re: Question about removing detail records under a master record 
> (master object with detail objects!)
>
> 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