Hibernate version:3.1
Hi all!
I have a problem with a Delete Statement.
I want to delete a object out of a Many-to-Many Relation (Tables Contact and Table Partner). If I just use session.delete(contact) then all contacts with the ID of this object are deleted (also in the association table -->in this table there is the Primary Key of Table Contact and the primary key of Table Partner)
So If the contact was binded to another Partner, this contact is ALSO deleted!
Here you see the SQL Hibernate makes:
Code:
Hibernate: /* delete collection com.magnasteyr.editool.hibernate.EtContacts.etEdiPartnerMany */ delete from EDITOOLS.ET_PA2CON where CON_ID=?
Hibernate: /* delete com.magnasteyr.editool.hibernate.EtContacts */ delete from EDITOOLS.ET_CONTACTS where CON_ID=?
But I only want to delete contacts out of the association table that have the ID of contact AND the ID of partner
I want something like that:
Code:
"Delete from EtContact c where c.etEdiPartnerMany.paId=:paId and
c.conId=:conId";
How can I achieve that?