No, not really. Hibernate doesn't do a "select count(*) from * where *.Cid = :CidBeingDeleted", because there is no (easy) way to find all references to C from any table. If only there was! The delete-orphan bit works on one-to-many and many-to-many relationships, and only on the relationship that the delete-orphan is defined on.
If you want to conditionally delete C in this case, your best bet is to add an sql-delete element in A's mapping, and do the delete in a stored procedure. That proc can check other relationships, and return 0 instead of deleting C, if C can't be deleted yet.
|