Hello,

Given entity A with 2 children B and CascadeType.REMOVE, deleting A may
produce queries something like this:

DELETE FROM B WHERE id = ? [params=(int) 2]
DELETE FROM A WHERE id = ? [params=(int) 1]
DELETE FROM B WHERE id = ? [params=(int) 3]

I have two issues with this: first since delete from A may be issued before
delete from B, the foreign key from B to A must not cascade and must be
deferrable. This may be a problem for integration with legacy code which
depends on the cascade.

Second, why issue individual deletes for each child entity? Wouldn't this be
more efficient (and best in this order)?
DELETE FROM B WHERE aFkId = ? [params=(int) 1]
DELETE FROM A WHERE id = ? [params=(int) 1]

-- 
Daryl Stultz
_____________________________________
6 Degrees Software and Consulting, Inc.
http://www.6degrees.com
mailto:[email protected]

Reply via email to