In our application we have about 20 CMP 2.0 beans! There are lots of relations 1:1, 1:N set! For most 1:N relations we have <cascade-delete/>! It was all working just fine until we decided to optimize for speed and set globally for JBoss:
Now we are not able do delete any bean participating in relation even though the relation is marked as <cascade-delete/>! When we try to delete such CMP an JDBC Exception is thrown stating violation of foreign key constraint.
Why setting "sync-on-commit-only" to "true" changes the order in which CMPs are deleted? Is this a bug or normal behavior?
Yes, it's a known issue. DELETE and INSERT are executed immediately. Only UPDATEs are done at commit. I plan to fix it.
To optimize cascade-delete, use batch-cascade-delete in jbosscmp-jdbc.xml for relationship roles that have cascade-delete in ejb-jar.xml. You can find a change note about it on sourceforge.