Hibernate version: 3.2
Hi folks,
I want to clear some parts of my database using data manipulation language (DML). More specifically to I have a n to m relationship between EntityA and EntityB and I want to remove all EntityA objects including their associations to EntityB.
As I have an n:m relationship there exists a table AtoB that has to be emptied before all entries in table A can get removed.
Is there a way to achieve that?
When using
Code:
query = session.createQuery("delete EntityA");
query.executeUpdate();
I'm getting foreign key exceptions regardless of the cascade options I set in the mapping on the n:m association, and
Code:
query = session.createQuery("delete EntityA.entityBs");
query.executeUpdate();
cannot be resolved even though my relation to EntityB is named entityBs.
Is there any other way to delete the association effectively besides using native SQL statements or making an explicit class out of the n:m association table?
Thanks in advance,
Joern