You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-dev@db.apache.org by Tuan Nguyen Minh <tu...@GlobalCybersoft.Com> on 2007/05/30 06:06:30 UTC

Cannot delete on many-to-many relationship

Hi all,
I'm a new user of derby. I have a problem want to support:
When executing the statement 
 
em.createQuery("delete from Subject").executeUpdate();
 
where Subject is in a many-to-many relationship with Book, and Subject
owns the relationship,
one expects that the corresponding entry in the SUBJECT_BOOK table would
be deleted.  This
happens when bulk deleting one-to-many relationships that are mapped
with a join table, as
well as for *-to-one relationships mapped with a foreign key.  It also
happens when individually
deleting objects.  However, it does not happen when bulk deleting the
owning side of a many-to-many
relationship.

 

Thanks & best regards,

    Tuan Nguyen


Re: Cannot delete on many-to-many relationship

Posted by Francois Orsini <fr...@gmail.com>.
Hello Tuan,

How are you handing referential integrity in your application? are you using
triggers or are you using referential contraints (cascade deletes) - Would
be helpful if you could post a bit more details about your data schema
definitions or/and a reproducible case...

Thanks, --francois

On 5/29/07, Tuan Nguyen Minh <tu...@globalcybersoft.com> wrote:
>
>  Hi all,
>
> I'm a new user of derby. I have a problem want to support:
>
> When executing the statement
>
>
>
> em.createQuery("delete from Subject").executeUpdate();
>
>
>
> where Subject is in a many-to-many relationship with Book, and Subject owns the relationship,
>
> one expects that the corresponding entry in the SUBJECT_BOOK table would be deleted.  This
>
> happens when bulk deleting one-to-many relationships that are mapped with a join table, as
>
> well as for *-to-one relationships mapped with a foreign key.  It also happens when individually
>
> deleting objects.  However, it does not happen when bulk deleting the owning side of a many-to-many
>
> relationship.
>
>
>
> Thanks & best regards,
>
>     Tuan Nguyen
>