cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mike Kienenberger <mkien...@gmail.com>
Subject Re: Question about removing detail records under a master record (master object with detail objects!)
Date Wed, 25 May 2011 20:01:33 GMT
What you are doing only alters a relationship.

You want to use this:

http://cayenne.apache.org/doc/api/org/apache/cayenne/ObjectContext.html#deleteObject%28java.lang.Object%29


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
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message