2 Replies Latest reply on Apr 26, 2002 7:49 AM by ibruell

    Strange relations

      Hi,

      i am using JBoss3.0.0RC1, J2SDK1.4 on Windows 2000 and try to use relations.

      I have the following beans:

      person (PK: mandant, number, type) and some attributes
      employee (PK: mandant, number) type as attribute and others.

      In this case i want to use one-to-one unidirectional relation.

      In the standard way JBoss generates additional columns in employee
      called person_mandant_id, person_number_id and person_type_id.

      But i won't that, because the attributes always exist and could be
      reused.

      if i use in jbosscmp-jdbc.xml:

      ---
      <ejb-relation>
      <ejb-relation-name>EmployeePerson</ejb-relation-name>
      <foreign-key-mapping/>
      <ejb-relationship-role>
      <ejb-relationship-role-name>employee-is-person</ejb-relationship-role-name>
      <key-fields>
      <key-field>
      <field-name>mandant</field-name>
      <column-name>mandant</column-name>
      </key-field>
      <key-field>
      <field-name>number</field-name>
      <column-name>number</column-name>
      </key-field>
      <key-field>
      <field-name>type</field-name>
      <column-name>type</column-name>
      </key-field>
      </key-fields>
      </ejb-relationship-role>
      <ejb-relationship-role>
      <ejb-relationship-role-name>person-employee</ejb-relationship-role-name>
      <key-fields/>
      </ejb-relationship-role>
      </ejb-relation>
      ---

      JBoss throws the message:

      ---
      org.jboss.deployment.DeploymentException: CMP field for key not found: field name=type
      at org.jboss.ejb.plugins.cmp.jdbc.metadata.JDBCRelationshipRoleMetaData.loadKeyFields(JDBCRe
      lationshipRoleMetaData.java:374)
      ---

      if i use this in jbosscmp-jdbc:

      ---
      <ejb-relation>
      <ejb-relation-name>EmployeePerson</ejb-relation-name>
      <foreign-key-mapping/>
      <ejb-relationship-role>
      <ejb-relationship-role-name>employee-is-person</ejb-relationship-role-name>
      <key-fields/>
      </ejb-relationship-role>
      <ejb-relationship-role>
      <ejb-relationship-role-name>person-employee</ejb-relationship-role-name>
      <key-fields>
      <key-field>
      <field-name>mandant</field-name>
      <column-name>mandant</column-name>
      </key-field>
      <key-field>
      <field-name>number</field-name>
      <column-name>number</column-name>
      </key-field>
      <key-field>
      <field-name>type</field-name>
      <column-name>type</column-name>
      </key-field>
      </key-fields>
      </ejb-relationship-role>
      </ejb-relation>
      ---

      than jboss throws thiss error:

      ---
      org.jboss.deployment.DeploymentException: CMP field for key not found: field name=type
      at org.jboss.ejb.plugins.cmp.jdbc.metadata.JDBCRelationshipRoleMetaData.loadKeyFields(JDBCRe
      lationshipRoleMetaData.java:374)
      ---

      What is the right way ?

        • 1. Re: Strange relations
          dsundstrom

          I have already responded to this on the jboss-user list. In the future pleas only post to the forum or the list. Here is a copy of my response:

          The first one is definitely wrong, but the second should work. Try it again and make sure the jar is correctly updated (common problem). If it doesn't go away, post a *simple* bug report with a test case at sourceforge.net.

          • 2. Re: Strange relations

            Now it works, the setter methods from the dependent bean wasn't in the remote interface