4 Replies Latest reply on Aug 4, 2004 4:30 AM by Alexey Loubyansky

    Problem with collection CMR field and ejb create

    Eugene Gluzberg Newbie

      I have two tables:

      addressable_table which has an addressabledbid (primary key) and some other columns
      gateway_table that has 3 columns:
      contactdbid (foreign key to addressable table addressabledbid)
      gateway_type (string)
      gateway_value (string)

      primary key for gateway_table is a contactdbid,gateway_type

      I have two entity beans and a 1-many relationship between them corrisponding to these two tables. I have cascade-delete and batch-cascade-delete turned on. relationship mapping is specified below.


      I am trying to do the following:

      addressableTable.getGateways().clear();
      while (more data)
      gatewayTableLocalHome.create(addressableTable,gatewayType,gatewayValue);


      It seems that the delete statement is not issued for the above clear call... I am getting a duplicate key exception during this operation..

      <ejb-relation>
      <ejb-relation-name>GatewayTableAddressableTable</ejb-relation-name>
      <ejb-relationship-role>
      <ejb-relationship-role-name>GatewayTableHasOneAddressableTable</ejb-relationship-role-name>
      Many
      <cascade-delete/>
      <relationship-role-source>
      <ejb-name>GatewayTable</ejb-name>
      </relationship-role-source>
      <cmr-field>
      <cmr-field-name>addressable</cmr-field-name>
      </cmr-field>
      </ejb-relationship-role>
      <ejb-relationship-role>
      <ejb-relationship-role-name>AddressableTableMayHaveManyGatewayTable</ejb-relationship-role-name>
      One
      <relationship-role-source>
      <ejb-name>AddressableTable</ejb-name>
      </relationship-role-source>
      <cmr-field>
      <cmr-field-name>gateways</cmr-field-name>
      <cmr-field-type>java.util.Collection</cmr-field-type>
      </cmr-field>
      </ejb-relationship-role>
      </ejb-relation>