openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daryl Stultz <>
Subject Cascade Delete
Date Tue, 09 Jun 2009 14:19:51 GMT

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.

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message