0 Replies Latest reply on Mar 26, 2002 5:41 PM by Alex Rublin

    Foreign Key

    Alex Rublin Newbie

      CMP2 with JBoss 3.0 beta2
      table A with fields a1, a2, a3
      table B with fields b1, a1

      a1 is a FK

      in BEJB a1 is not a cmp-field but cmr-field
      ejb-jar.xml
      ----------

      <ejb-relation>
      <ejb-relation-name>B-A</ejb-relation-name>
      <ejb-relationship-role>
      <ejb-relationship-role-name>b-has-a</ejb-relationship-role-name>
      One
      <relationship-role-source>
      <ejb-name>BEJB</ejb-name>
      </relationship-role-source>
      <cmr-field>
      <cmr-field-name>fka1</cmr-field-name>
      </cmr-field>
      </ejb-relationship-role>
      <ejb-relationship-role>
      <ejb-relationship-role-name>a-belongsto-b
      </ejb-relationship-role-name>
      One
      <relationship-role-source>
      <ejb-name>AEJB</ejb-name>
      </relationship-role-source>
      </ejb-relationship-role>
      </ejb-relation>

      ----------

      jbosscmp-jdbc.xml
      ------

      <ejb-relation>
      <ejb-relation-name>B-A</ejb-relation-name>
      <foreign-key-mapping>
      <ejb-relationship-role>
      <ejb-relationship-role-name>b-has-a</ejb-relationship-role-name>
      <foreign-key-fields>
      <foreign-key-field>
      <field-name>fka1</field-name>
      <column-name>a1</column-name>
      </foreign-key-field>
      </foreign-key-fields>
      </ejb-relationship-role>
      <ejb-relationship-role>
      <ejb-relationship-role-name>a-belongsto-a</ejb-relationship-role-name>
      <foreign-key-fields/>
      </ejb-relationship-role>
      </foreign-key-mapping>
      </ejb-relation>

      --------------------
      While calling iterator.(next) in Debug mode I see the SQL statement as follows:

      14:06:00,840 DEBUG [AEJB] Executing SQL: SELECT a2, a3, BEJB_fka1 FROM T_A WHERE (a1=?)

      Question: why container concatinates alias BEJB_fka1 ?
      Of course it fails later.

      What wrong with that?
      Thanks