3 Replies Latest reply on May 15, 2002 4:19 PM by Tim Fox

    JBoss3 RC1: jbosscmp-jdbc.xml relationship settings has no e

    Andrew Lau Newbie

      I made a jbosscmp-jdbc.xml file specifying what join table and what foreign key to be used. However, jboss ignores my settings and keep using the default.

      My jbosscmp-jdbc.xml file is as follows:

      ----------------------------
      <jbosscmp-jdbc>
      <enterprise-beans>

      <ejb-name>TestEntity3</ejb-name>
      <table-name>TestEntityTable3</table-name>
      <cmp-field>
      <field-name>column1</field-name>
      <column-name>column1</column-name>
      <jdbc-type>VARCHAR</jdbc-type>
      <sql-type>VARCHAR(50)</sql-type>
      </cmp-field>
      <eager-load>
      <field-name>column1</field-name>
      </eager-load>
      java:/OracleDS
      <type-mapping>Oracle8</type-mapping>
      true
      <create-table>false</create-table>
      <remove-table>false</remove-table>
      <read-only>false</read-only>
      <time-out>300</time-out>
      <select-for-update>false</select-for-update>
      <pk-constraint>false</pk-constraint>
      <!-- <read-ahead>true</read-ahead> -->


      <ejb-name>TestEntity4</ejb-name>
      <table-name>TestEntityTable4</table-name>
      <cmp-field>
      <field-name>column1</field-name>
      <column-name>column1</column-name>
      <jdbc-type>VARCHAR</jdbc-type>
      <sql-type>VARCHAR(50)</sql-type>
      </cmp-field>
      <cmp-field>
      <field-name>column2</field-name>
      <column-name>column2</column-name>
      <jdbc-type>VARCHAR</jdbc-type>
      <sql-type>VARCHAR(50)</sql-type>
      </cmp-field>
      <eager-load>
      <field-name>column1</field-name>
      </eager-load>
      java:/OracleDS
      <type-mapping>Oracle8</type-mapping>
      true
      <create-table>false</create-table>
      <remove-table>false</remove-table>
      <read-only>false</read-only>
      <time-out>300</time-out>
      <select-for-update>false</select-for-update>
      <pk-constraint>false</pk-constraint>
      <!-- <read-ahead>true</read-ahead> -->


      <ejb-name>TestEntity5</ejb-name>
      <table-name>TestEntityTable5</table-name>
      <cmp-field>
      <field-name>column1</field-name>
      <column-name>column1</column-name>
      <jdbc-type>VARCHAR</jdbc-type>
      <sql-type>VARCHAR(50)</sql-type>
      </cmp-field>
      <eager-load>
      <field-name>column1</field-name>
      </eager-load>
      java:/OracleDS
      <type-mapping>Oracle8</type-mapping>
      true
      <create-table>false</create-table>
      <remove-table>false</remove-table>
      <read-only>false</read-only>
      <time-out>300</time-out>
      <select-for-update>false</select-for-update>
      <pk-constraint>false</pk-constraint>
      <!-- <read-ahead>true</read-ahead> -->

      </enterprise-beans>

      <ejb-relation>
      <ejb-relation-name>testEntity4-testEntity5</ejb-relation-name>
      <foreign-key-mapping>
      <ejb-relationship-role>
      <ejb-relationship-role-name>TestEntity4RelationshipRole</ejb-relationship-role-name>
      <foreign-key-fields/>
      </ejb-relationship-role>
      <ejb-relationship-role>
      <ejb-relationship-role-name>TestEntity5RelationshipRole</ejb-relationship-role-name>
      <foreign-key-fields>
      <foreign-key-field>
      <field-name>column1</field-name>
      <column-name>testEntity4Foreign1</column-name>
      </foreign-key-field>
      <foreign-key-field>
      <field-name>column2</field-name>
      <column-name>testEntity4Foreign2</column-name>
      </foreign-key-field>
      </foreign-key-fields>
      </ejb-relationship-role>
      </foreign-key-mapping>
      </ejb-relation>

      <ejb-relation>
      <ejb-relation-name>testEntity3-testEntity4</ejb-relation-name>
      <table-mapping>
      <table-name>Table3JoinTable4</table-name>
      <create-table>true</create-table>
      <remove-table>false</remove-table>

      <ejb-relationship-role>
      <ejb-relationship-role-name>
      TestEntity3RelationshipRole
      </ejb-relationship-role-name>
      <table-key-fields>
      <table-key-field>
      <field-name>column1</field-name>
      <column-name>Table3Column1</column-name>
      </table-key-field>
      </table-key-fields>
      </ejb-relationship-role>

      <ejb-relationship-role>
      <ejb-relationship-role-name>
      TestEntity4RelationshipRole
      </ejb-relationship-role-name>
      <table-key-fields>
      <table-key-field>
      <field-name>column1</field-name>
      <column-name>Table4Column1</column-name>
      </table-key-field>
      <table-key-field>
      <field-name>column2</field-name>
      <column-name>Table4Column2</column-name>
      </table-key-field>
      </table-key-fields>
      </ejb-relationship-role>
      </table-mapping>
      </ejb-relation>

      </jbosscmp-jdbc>

      --------------------

      I am trying to tell JBoss to use a join table called 'Table3JoinTable4'. But that table didn't get created during deploy.

      I then run a test and then I look at the log to see what JBoss is doing, I found the following queries, among others:

      .....

      SELECT TestEntity3 FROM TESTENTITY3_TESTENTIT_1BB232R WHERE (TestEntity4_column2=? AND TestEntity4_column1=?)

      .....

      INSERT INTO TESTENTITYTABLE5 (column1, testEntity4_column2, testEntity4_column1) VALUES (?, ?, ?)

      .....

      It seems that JBoss just ignore my jbosscmp-jdbc.xml file; it uses a join table called 'TESTENTITY3_TESTENTIT_1BB232R' which probably is the default join table name(?).

      Did I do something wrong? Any help is very much appreciated, thank you very much!

      Andrew