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

    Strange relations

    Ingo Bruell Newbie

      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 ?