Hi all,
AppServer version: BES 5.2.1 with patches 1 to 22.
DB: ORACLE 9i.
Use of CMP entity beans.
My entity bean A is involved in a 1:n relationship with an entity B, which is itself involved in another 1:n relationship with entity C. Both relationships have 'cascade-delete' enabled. The ejbRemove() methods of all beans aren't overriden.
When I try to delete entity A, I get a PersistenceException saying that the server could not delete B because of referential integrity violation. It seems that the EJB container ignores the relationship between B and C when deleting B.
Is it a known bug of BES? Are there any workarounds?
Thanks for any answer. Regards,
Baptiste
-
[BES] multilevel cascade-delete error (2 messages)
- Posted by: Bobby McGee
- Posted on: March 03 2004 11:57 EST
Threaded Messages (2)
- [BES] multilevel cascade-delete error by Paul Strack on March 04 2004 10:34 EST
- [BES] multilevel cascade-delete error by Krishnan Subramanian on March 05 2004 12:21 EST
-
[BES] multilevel cascade-delete error[ Go to top ]
- Posted by: Paul Strack
- Posted on: March 04 2004 10:34 EST
- in response to Bobby McGee
I don't know if this is a known bug, but there is a work-around:
Explicitly delete the extra records in the ejbRemove() method. This is crude, but better than nothing. -
[BES] multilevel cascade-delete error[ Go to top ]
- Posted by: Krishnan Subramanian
- Posted on: March 05 2004 12:21 EST
- in response to Bobby McGee
Bapiste,
I just tried things with BES 5.2.1 with patches and things worked a-ok (I was
using JDataStore, but that should not matter).
With the JVM flag on the partition:
-DDataSourceDebug
this was the SQL sent to the database when I had three entity beans A, B
and C. A - B is a one-to-many bi-directional relationship, B - C is also a
one-to-many bi-directional relationship. The SQL sent to the database by
the CMP engine when I invoked a "AHome.findByPK(pk).remove()" is:
SELECT AID, AVALUE FROM A WHERE AID=?
SELECT AID, BID, BVALUE FROM B WHERE AID=?
SELECT BID, CID, CVALUE FROM C WHERE BID=?
DELETE FROM C WHERE BID =?
DELETE FROM B WHERE AID =?
DELETE FROM A WHERE AID = ?
The above is the correct order for removal . . . and no exceptions were
thrown by the CMP engine. I could send you my sample project & DB.
I suspect, you might have incorrectly defined the cascade-delete behavior
in the XML Descriptors.
-krish
The complete output from the patches I have installed:
ejbcontainer: : E:\Borland\BES521\lib\partition.jar
ejbcontainer: : E:\Borland\BES521\lib\patches\bes521_p1.jar
ejbcontainer: : E:\Borland\BES521\lib\patches\bes521_p12.jar
ejbcontainer: : E:\Borland\BES521\lib\patches\bes521_p13.jar
ejbcontainer: : E:\Borland\BES521\lib\patches\bes521_p15.jar
ejbcontainer: : E:\Borland\BES521\lib\patches\bes521_p17.jar
ejbcontainer: : E:\Borland\BES521\lib\patches\bes521_p2.jar
ejbcontainer: : E:\Borland\BES521\lib\patches\bes521_p3.jar
ejbcontainer: : E:\Borland\BES521\lib\patches\bes521_p4.jar
ejbcontainer: : E:\Borland\BES521\lib\patches\bes521_p5.jar
ejbcontainer: : E:\Borland\BES521\lib\patches\bes521_p7.jar
ejbcontainer: : E:\Borland\BES521\lib\patches\bes521_p9.jar
ejbcontainer: : E:\Borland\BES521\lib\ias.jar
ejbcontainer: : E:\Borland\BES521\lib\lm.jar
ejbcontainer: : E:\Borland\BES521\lib\asrt.jar
ejbcontainer: : E:\Borland\BES521\lib\orgomg.jar
ejbcontainer: : E:\Borland\BES521\lib\vbjorb.jar
ejbcontainer: : E:\Borland\BES521\lib\vbsec.jar
ejbcontainer: : E:\Borland\BES521\lib\jsse.jar
ejbcontainer: : E:\Borland\BES521\lib\jaas.jar
ejbcontainer: : E:\Borland\BES521\lib\jcert.jar
ejbcontainer: : E:\Borland\BES521\lib\jnet.jar
ejbcontainer: : E:\Borland\BES521\lib\jce1_2_1.jar
ejbcontainer: : E:\Borland\BES521\lib\local_policy.jar
ejbcontainer: : E:\Borland\BES521\lib\sunjce_provider.jar
ejbcontainer: : E:\Borland\BES521\lib\US_export_policy.jar
ejbcontainer: : E:\Borland\BES521\lib\xmlrt.jar
ejbcontainer: : E:\Borland\BES521\lib\vbjdev.jar
ejbcontainer: : E:\Borland\BES521\lib\vbdev.jar
ejbcontainer: : E:\Borland\BES521\lib\vbejb.jar
ejbcontainer: : E:\Borland\BES521\lib\tomcat4.jar
ejbcontainer: : E:\Borland\BES521\lib\jdsserver.jar
ejbcontainer: : E:\Borland\BES521\SonicMQ\lib\broker.jar
ejbcontainer: : E:\Borland\BES521\lib\visiconnect.jar
ejbcontainer: : E:\Borland\BES521\lib\tomcat\common\servlet.jar
ejbcontainer: : E:\Borland\BES521\lib\tomcat\common\naming-common.jar
ejbcontainer: : E:\Borland\BES521\lib\tomcat\common\naming-resources.jar
ejbcontainer: : E:\Borland\BES521\lib\tomcat\common\naming-factory.jar
ejbcontainer: : E:\Borland\BES521\lib\tomcat\common\commons-collections.jar
ejbcontainer: : E:\Borland\BES521\lib\tomcat\common\commons-logging-api.jar
ejbcontainer: : E:\Borland\BES521\lib\tomcat\common\ant.jar
ejbcontainer: : E:\Borland\BES521\var\servers\krish\partitions\jbuilder\classes
ejbcontainer: : E:\Borland\BES521\var\servers\krish\partitions\jbuilder\lib\BesToWls.jar
ejbcontainer: : E:\Borland\BES521\var\servers\krish\partitions\jbuilder\lib\weblogic.jar
ejbcontainer: : E:\Borland\BES521\var\servers\krish\partitions\jbuilder\lib\webservices.jar
ejbcontainer: : E:\Borland\BES521\var\servers\krish\partitions\classes
ejbcontainer: : F:\j2sdk1.4.2_03\lib\tools.jar