Hibernate version:
3.1.3
Hi, I don't want to get into the technical details here as my question is of a more general nature.
I have a many-to-many association between classes A and B. There are parents and children in the table A. So if I want to delete the associations to B's for a parent, I also want to delete them for it's children. Now I'd like to do this with only ONE delete statement send to the database.
To further illustrate this: Let's say, we have the following instances and associations:
Code:
parent: a1 -> b1, b2
child: a2 -> b2, b3
I want to delete these associations so that I have this in the end:
Code:
parent: a1 -> --
child: a2 -> --
So far, Hibernate issues two delete statements, one for each collection of B's in each A. Is there a possibility to get this down to just ONE statement, and how? No matter if I used a HQL query or a Criteria, I always ended with two delete statements whereas I'm looking for something which results in this kind of SQL: 'delete from JOINTABLE where ID_A in (select ID from A where PARENT_ID = '...' )'