Chapter 8 Creating J2EE Applications for BEA WebLogic
The purpose of the db-cascade-delete method is to allow an application to take advantage of a database's built-in support for cascade delete, and possibly improve performance. If the db-cascade-delete element is not specified, it is important not to enable any of the database's cascade delete functionality, as this will produce incorrect results.
The db-cascade-delete element specifies that a cascade delete will use the built-in cascade delete facilities of the underlying DBMS. By default, this feature is turned off and the EJB container removes the beans involved in a cascade delete by issuing an individual SQL DELETE statement for each bean.
If db-cascade-delete element is specified in the weblogic-cmp-rdbms-jar.xml, the cascade-delete element must also be specified in the ejb-jar.xml.
When db-cascade-delete is enabled, an additional database table setup is required. For example, the following setup for the Oracle database table will cascade delete all of the employees if the dept is deleted in the database.
CREATE TABLE dept (deptno NUMBER(2) CONSTRAINT pk_dept PRIMARY KEY, dname VARCHAR2(9) ); CREATE TABLE emp (empno NUMBER(4) PRIMARY KEY, ename VARCHAR2(10), deptno NUMBER(2) CONSTRAINT fk_deptno REFERENCES dept(deptno) ON DELETE CASCADE );
Copyright (C) 2005. Sybase Inc. All rights reserved. |
![]() |