0 Replies Latest reply on Apr 12, 2002 1:17 PM by lairi

    Pb using relations jboss 3_00

    lairi

      Hi,

      The pb is :
      With a relation one to many, unable to get the beanlocalobject when using findbyprimarykey on the many side : an exception is thrown java.lang.IllegalArgumentException: object is not an instance of declaring class

      Settings
      there are 2 tables: A and B
      A: primarykey=a_pk
      B: primarykey=(a_pk,b_pk) , foreignkey=a_pk

      in ejb-jar.xml
      <ejb-relationship-role>
      <ejb-relationship-role-name>B-has-A</ejb-relationship-role-name>
      Many
      <relationship-role-source>
      <ejb-name>B</ejb-name>
      </relationship-role-source>
      <cmr-field>
      <cmr-field-name>a_pk</cmr-field-name>
      </cmr-field>
      </ejb-relationship-role>

      <ejb-relationship-role>
      <ejb-relationship-role-name>A-has-Bs</ejb-relationship-role-name>
      One
      <relationship-role-source>
      <ejb-name>A</ejb-name>
      </relationship-role-source>
      <cmr-field>
      <cmr-field-name>bs</cmr-field-name>
      <cmr-field-type>java.util.Collection</cmr-field-type>
      </cmr-field>
      </ejb-relationship-role>


      in the jbosscmp-jdbc.xml
      <ejb-relation-name>A-B</ejb-relation-name>
      <foreign-key-mapping>
      <ejb-relationship-role>
      <ejb-relationship-role-name>A-has-Bs</ejb-relationship-role-name>
      <fk-constraint>false</fk-constraint>
      <foreign-key-fields/>
      </ejb-relationship-role>
      <ejb-relationship-role>
      <ejb-relationship-role-name>B-has-A</ejb-relationship-role-name>
      <foreign-key-field>
      <field-name>a_pk</field-name>
      <column-name>A_PK</column-name>
      </foreign-key-field>
      </ejb-relationship-role>
      </foreign-key-mapping>

      In the beans :
      A :
      has a getBS() that return a Collection
      a_pk is declared as a cmp field

      B :
      a_pk is declared as a cmp field and (cmr field in ejb_jar)
      getA_pk(), setA_pk(type_of_a_pk)
      b_pk is declared as a cmp field

      Can anyone help me