4 Replies Latest reply on Jul 14, 2004 6:01 AM by aloubyansky

    jbosscmp-jdbc.xml relationship mapping dbindex problems

    garek

      Hi,

      I'm using jboss 3.2.5 with mysql 4.0.18. However, I'm having problems when I try to have Jboss create indexes on foreign keys when it creates tables.

      For example, I have two entity beans, ItemEJB and ItemQuantitiesEJB, in a one-to-many relationship. ItemEJB has a primary key field called itemId and ItemQuantitiesEJB has a foreign key column called ItemEJB_foreignKey, which corresponds to the itemId field in ItemEJB.

      When I deploy the application, the tables are created, and then Jboss creates an index on the ItemEJB_foreignKey field in the ItemQuantitiesEJB table, which is what I want.

      But here is the problem, Jboss then tries to create an index on a field called ItemEJB_foreignKey in the ItemEJB table - but this field does not exist, causing an sql exception to be thrown.

      Here's the relationship mapping from the jbosscmp-jdbc.xml file:

      <ejb-relation>
       <ejb-relation-name>Item-Quantity</ejb-relation-name>
       <foreign-key-mapping />
       <ejb-relationship-role>
       <ejb-relationship-role-name>
       Item-has-many-Quantity
       </ejb-relationship-role-name>
       <key-fields>
       <key-field>
       <field-name>id</field-name>
       <column-name>ItemEJB_foreignKey</column-name>
       <dbindex />
       </key-field>
       </key-fields>
       </ejb-relationship-role>
       <ejb-relationship-role>
       <ejb-relationship-role-name>
       Quantity-belongs-to-a-Item
       </ejb-relationship-role-name>
       <batch-cascade-delete />
       </ejb-relationship-role>
      </ejb-relation>
      
      
      Is there something I'm missing?

      Thanks,
      Brian