0 Replies Latest reply on Oct 23, 2003 2:24 PM by Urs Wagner

    Why will auto create the foreign key

    Urs Wagner Novice

      I have the following entry in ejb-jar.xml and jbosscmp-jdbc.xml



      <ejb-relation>
      <ejb-relation-name>member-person</ejb-relation-name>
      <ejb-relationship-role>
      <ejb-relationship-role-name>person</ejb-relationship-role-name>
      Many
      <cascade-delete/>
      <relationship-role-source>
      <ejb-name>MemberEJB</ejb-name>
      </relationship-role-source>
      <cmr-field>
      <cmr-field-name>person</cmr-field-name>
      </cmr-field>
      </ejb-relationship-role>
      <ejb-relationship-role>
      <ejb-relationship-role-name>membership</ejb-relationship-role-name>
      One
      <relationship-role-source>
      <ejb-name>PersonEJB</ejb-name>
      </relationship-role-source>
      <cmr-field>
      <cmr-field-name>members</cmr-field-name>
      <cmr-field-type>java.util.Set</cmr-field-type>
      </cmr-field>
      </ejb-relationship-role>
      </ejb-relation>


      <ejb-relation>

      <ejb-relation-name>member-person</ejb-relation-name>
      <foreign-key-mapping/>
      <ejb-relationship-role>
      <ejb-relationship-role-name>membership</ejb-relationship-role-name>
      <key-fields>
      <key-field>
      <field-name>peid</field-name>
      <column-name>person</column-name>
      </key-field>
      </key-fields>
      </ejb-relationship-role>
      <ejb-relationship-role>

      <ejb-relationship-role-name>person</ejb-relationship-role-name>
      <fk-constraint>true</fk-constraint>
      <key-fields/>
      <read-ahead>
      on-load
      </read-ahead>
      </ejb-relationship-role>
      </ejb-relation>

      The table and primary are created automatically, but no foreign key. Have I forgotten something?

      Thanks for Your help.