posted 21 years ago
I have two beans (A and B) and their associated tables are defined as:
[table A]
name varchar
id integer
other columns...
primarykey is (name, id) which is defined as APK.class
[table B]
name varchar
id integer
bname varchar
other columns...
primarykey is (name, id, bname) which is defined as BPK.class
Question: How do I setup the relationship between A and B to perform
cascade delete (i.e. deleting A would automatically delete associated
B)? The database tables (oracle) are already setup to do cascade delete.
I've tried this but get an error when running appc (In relationship 'A-
B', role 'B-Has-One-A', a cmp-field used to implement this relationship
has a primitive type. All cmp-fields that double as cmr-fields must have
an object type.)
in ejb-jar.xml:
<relationships>
<ejb-relation>
<ejb-relation-name>A-B</ejb-relation-name>
<ejb-relationship-role>
<ejb-relationship-role-name>A-Has-Many-B</ejb-relationship-role-name>
<multiplicity>one</multiplicity>
<relationship-role-source>
<ejb-name>AEJB</ejb-name>
</relationship-role-source>
<cmr-field>
<cmr-field-name>brecs</cmr-field-name>
<cmr-field-type>java.util.Collection</cmr-field-type>
</cmr-field>
</ejb-relationship-role>
<ejb-relationship-role>
<ejb-relationship-role-name>B-Has-One-A</ejb-relationship-role-name>
<multiplicity>many</multiplicity>
<cascade-delete/>
<relationship-role-source>
<ejb-name>BEJB</ejb-name>
</relationship-role-source>
</ejb-relationship-role>
</ejb-relation>
</relationships>
in weblogic-ejb-jar.xml:
<weblogic-rdbms-relation>
<relation-name>A-B</relation-name>
<weblogic-relationship-role>
<relationship-role-name>B-Has-One-A</relationship-role-name>
<relationship-role-map>
<column-map>
<foreign-key-column>name</foreign-key-column>
<key-column>name</key-column>
</column-map>
<column-map>
<foreign-key-column>id</foreign-key-column>
<key-column>id</key-column>
</column-map>
</relationship-role-map>
<db-cascade-delete/>
</weblogic-relationship-role>
</weblogic-rdbms-relation>