0 Replies Latest reply on Oct 20, 2003 5:50 AM by fredatwork

    Cascade delete does not work

    fredatwork Newbie

      Hello,

      I try to put at work my first <cascade-delete> tag with no success. (note: i'm a newbee with cascade deleting).

      The involved relationship is a bi-derectional "One to Many" relation between EJB's 'Strategy' and 'OrderedSignals'.

      Here is the relevant part of my ejb-jar.xml file (Xdoclet-generated) :

      <ejb-relation-name>Strategy-OrderedSignals</ejb-relation-name>
      <ejb-relationship-role >
      <ejb-relationship-role-name>OrderedSignal relates to a strategy</ejb-relationship-role-name>
      Many
      <cascade-delete/>
      <relationship-role-source >
      <ejb-name>OrderedSignal</ejb-name>
      </relationship-role-source>
      <cmr-field >
      <cmr-field-name>strategy</cmr-field-name>
      </cmr-field>
      </ejb-relationship-role>

      <ejb-relationship-role >
      <ejb-relationship-role-name>Strategy is made out of several signals</ejb-relationship-role-name>
      One
      <relationship-role-source >
      <ejb-name>Strategy</ejb-name>
      </relationship-role-source>
      <cmr-field >
      <cmr-field-name>orderedSignals</cmr-field-name>
      <cmr-field-type>java.util.Collection</cmr-field-type>
      </cmr-field>
      </ejb-relationship-role>
      </ejb-relation-name>

      When I delete a 'Strategy' taht has one or many chilfren ('OrderedSignal'), my transaction gets rooled back.
      13:35:38,114 ERROR [LogInterceptor] TransactionRolledbackLocalException in method: public abstract void javax.ejb.EJBLocalObject.remove() throws javax.ejb.RemoveException,javax.ejb.EJBException, causedBy:
      javax.ejb.EJBException: Update failed. Expected one affected row: rowsAffected=0id=22
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreEntityCommand.execute(JDBCStoreEntityCommand.java:163)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.storeEntity(JDBCStoreManager.java:651)
      at org.jboss.ejb.plugins.CMPPersistenceManager.storeEntity(CMPPersistenceManager.java:443)
      at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.storeEntity(CachedConnectionInterceptor.java:388)
      at org.jboss.ejb.EntityContainer.storeEntity(EntityContainer.java:703)

      Note that if I get rid of the <cascade-delete> tag and I manage the removal from the application, everything works.

      Thanks in advance for your help.

      Fred