6 Replies Latest reply on Mar 12, 2003 10:26 AM by Phyo Kyaw

    Problem with CMR with auto-increment primary key in JBoss 3.

    Fendy Newbie

      I am currently using JBoss 3.2RC1. I am able to get CMP to work with auto-increment primary key support in the 3.2 feature. However, to get auto-increment primary key to work in CMP, the primary key field cannot be declared in the ejb-jar.xml, nor the jbosscmp-jdbc.xml file. However, to setup CMR, the mapping requires a foreign key to be mapped to a cmp-field, in this case the auto-increment primary key. But the auto-increment primary key must not be declared in order to for CMP to work. Any one has any solution?

      The jbosscmp-jdbc.xml file content
      <jbosscmp-jdbc>

      java:/MSSQLDS
      <datasource-mapping>MS SQLSERVER</datasource-mapping>
      <create-table>false</create-table>
      <remove-table>false</remove-table>
      <enterprise-beans>

      <ejb-name>AddressEJB</ejb-name>
      <table-name>TAddress</table-name>
      <cmp-field>
      <field-name>street1</field-name>
      <column-name>Street1</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>street2</field-name>
      <column-name>Street2</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>city</field-name>
      <column-name>City</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>state</field-name>
      <column-name>State</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>postalCode</field-name>
      <column-name>PostalCode</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>country</field-name>
      <column-name>Country</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>lastUpdated</field-name>
      <column-name>LastUpdated</column-name>
      </cmp-field>
      <unknown-pk>
      <unknown-pk-class>java.lang.Integer</unknown-pk-class>
      <column-name>AddressId</column-name>
      <jdbc-type>INTEGER</jdbc-type>
      <sql-type>INTEGER</sql-type>
      </unknown-pk>
      <entity-command name="get-generated-keys"/>


      <ejb-name>UserInfoEJB</ejb-name>
      <table-name>TUserInfo</table-name>
      <cmp-field>
      <field-name>userInfoId</field-name>
      <column-name>UserInfoId</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>title</field-name>
      <column-name>Title</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>firstName</field-name>
      <column-name>FirstName</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>lastName</field-name>
      <column-name>LastName</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>personalPhoneNumber</field-name>
      <column-name>PersonalPhoneNumber</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>faxNumber</field-name>
      <column-name>FaxNumber</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>businessPhoneNumber</field-name>
      <column-name>BusinessPhoneNumber</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>joinDate</field-name>
      <column-name>JoinDate</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>notes</field-name>
      <column-name>Notes</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>lastUpdated</field-name>
      <column-name>LastUpdated</column-name>
      </cmp-field>
      <unknown-pk>
      <unknown-pk-class>java.lang.Integer</unknown-pk-class>
      <column-name>UserInfoId</column-name>
      <jdbc-type>INTEGER</jdbc-type>
      <sql-type>INTEGER</sql-type>
      </unknown-pk>
      <entity-command name="get-generated-keys"/>

      </enterprise-beans>

      <ejb-relation>
      <ejb-relation-name>UserInfo-Address</ejb-relation-name>
      <foreign-key-mapping/>
      <ejb-relationship-role>
      <ejb-relationship-role-name>userinfo-has-an-address</ejb-relationship-role-name>
      <key-fields>
      <key-field>
      <field-name>address</field-name>
      <column-name>AddressId</column-name>
      </key-field>
      </key-fields>
      </ejb-relationship-role>
      <ejb-relationship-role>
      <ejb-relationship-role-name>address-assignedTo-userinfo</ejb-relationship-role-name>
      <key-fields/>
      </ejb-relationship-role>
      </ejb-relation>

      </jbosscmp-jdbc>