In Hibernate3.1x it is possible to use DML-style for update/insert/delete operations on Hibernate entities. Suppose I have an object graph that I need to remove by deleting parent object.
In non-DML style it would look like:
which would cause cascade deletion for all child objects with cascade="all" in mapping file.
Correspondent DML-style will be similar to this:
This would produce SQL, similar to the following:
String hqlUpdate = "delete SomeObject someObject where someObject.id = :id";
This would cause runtime error due to possible database data integrity constraint (assume no cascade propagation constrains on database level).
DELETE FROM SOME_OBJECT WHERE SOME_OBJECT_ID=?
The question is - how to tell Hiberante to traverse whole object graph for cascade update/delete in DML-style update/delete impl. ?