This content has been marked as final. Show 2 replies
You have to configure this in the jbosscmp-jdbc.xml file. In my file, I have the following code in the defaults section:
<unknown-pk> <unknown-pk-class>java.lang.Long</unknown-pk-class> <field-name>id</field-name> <column-name>ID</column-name> <jdbc-type>BIGINT</jdbc-type> <sql-type>BIGINT</sql-type> <auto-increment/> </unknown-pk> <entity-command name="mysql-get-generated-keys"/>
The unknown-pk section sets up the default values that JBoss will use when it encounters an unknown primary key. The entity-command section tells JBoss how to get the information on the key generated by the database.
Of course, for most entities sticking to a column named 'ID' isn't very cool, so in each entity where I use an unknown primary key, I can add an entity-specific unknown-pk element to configure the column name for that entity:
<unknown-pk> <unknown-pk-class>java.lang.Long</unknown-pk-class> <field-name>userId</field-name> <column-name>USER_ID</column-name> </unknown-pk>
Great - Amazing
We were missing the <field-name> and <column-name> that was all :-)
Thanks again Great response.