GeeCON Prague 2014*
The moose likes JBoss/WildFly and the fly likes cascade-delete doesn't work Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Products » JBoss/WildFly
Bookmark "cascade-delete doesn Watch "cascade-delete doesn New topic
Author

cascade-delete doesn't work

Pablo Delgado
Greenhorn

Joined: Apr 18, 2003
Posts: 1
Hi,
I'm using postgres 7.3.2 and jboss 3.2 and my problem is that the tag <cascade-delete/> in a one-to-many relationship doesn't work
B (1) ----- (*) A
I have my relation like this in the ejb-jar.xml
<ejb-relation> <ejb-relation-name>A-B</ejb-relation-name>
<ejb-relationship-role> <ejb-relationship-role-name>A-belongs-to-B</ejb-relationship-role-name>
<multiplicity>Many</multiplicity>
<cascade-delete/>
<relationship-role-source >
<ejb-name>A</ejb-name>
</relationship-role-source>
<cmr-field >
<cmr-field-name>token</cmr-field-name>
</cmr-field>
</ejb-relationship-role>
<ejb-relationship-role> <ejb-relationship-role-name>B-has-Aes</ejb-relationship-role-name>
<multiplicity>One</multiplicity>
<relationship-role-source >
<ejb-name>B</ejb-name>
</relationship-role-source>
<cmr-field>
<cmr-field-name>availabilities</cmr-field-name>
<cmr-field-type>java.util.Collection</cmr-field-type>
</cmr-field>
</ejb-relationship-role>
</ejb-relation>
and in the jbosscmp-jdbc.xml ...
<ejb-relation>
<ejb-relation-name>A-B</ejb-relation-name>
<foreign-key-mapping/>
<ejb-relationship-role> <ejb-relationship-role-name>A-belongs-to-A</ejb-relationship-role-name>
<fk-constraint>true</fk-constraint>
<key-fields/>
</ejb-relationship-role>
<ejb-relationship-role> <ejb-relationship-role-name>B-has-Aes</ejb-relationship-role-name>
<key-fields>
<key-field>
<field-name>idtoken</field-name>
<column-name>id_token_fk</column-name>
</key-field>
</key-fields>
</ejb-relationship-role>
</ejb-relation>
and it creates the table A in my Postgres DB like this ...
Table "public.A"
Column | Type | Modifiers
-------------+---------+-----------
id_token_fk | bigint | not null
occupation | integer | not null
Indexes: pk_A primary key btree (id_token_fk, occupation)
Foreign Key constraints: fk_useoccupation_token FOREIGN KEY (id_token_fk) REFERENCES B (id_token) ON UPDATE NO ACTION ON DELETE NO ACTION
but it should have created it with this CONSTRAINT ...
Foreign Key constraints: fk_useoccupation_token FOREIGN KEY (id_token_fk) REFERENCES B (id_token) ON UPDATE CASCADE ON DELETE NO CASCADE
It's like the tag <cascade-delete/> didn't work.
Please, I'd appreciate any help.
Thanks.
Pablo
Anny liu
Greenhorn

Joined: Jun 16, 2004
Posts: 1
How was this problem solved? I met the same with you,so i want to know the answer.
 
GeeCON Prague 2014
 
subject: cascade-delete doesn't work