With MySQL you can have AutoIncrement Primary Key Fields without using Unknown-PK's  

BUT you have to let JBoss create the Database (or make sure you create it correctly to 
match what JBoss is looking for. 

The key is to dec;are your PK in jbosscmp-jdbc.xml as 

<auto-increment/> 

and have the 

      <entity-command name="mysql-get-generated-keys"
                      
class="org.jboss.ejb.plugins.cmp.jdbc.keygen.JDBCMySQLCreateCommand"/>

in the entity

we have our system set up as follows

  | <entity>
  |   <ejb-name>AdminRolesBean</ejb-name>
  |   <table-name>admin_roles</table-name>
  |   <cmp-field>
  |     <field-name>id</field-name>
  |     <column-name>ar_id</column-name>
  |     <not-null/>
  |     <auto-increment/>
  |   </cmp-field>
  |   <entity-command name="mysql-get-generated-keys"
  |   class="org.jboss.ejb.plugins.cmp.jdbc.keygen.JDBCMySQLCreateCommand"/>
  | </entity>           
  |     
  | 

our ejb-jar is as follows


  | <entity>
  |  <ejb-name>AdminRolesBean</ejb-name>
  |  <home>com.ingotz.points.core.entity.AdminRolesHome</home>
  |  <remote>com.ingotz.points.core.entity.AdminRoles</remote>
  |  <local-home>com.ingotz.points.core.entity.AdminRolesLocalHome</local-home>
  |  <local>com.ingotz.points.core.entity.AdminRolesLocal</local>
  |  <ejb-class>com.ingotz.points.core.entity.AdminRolesBean</ejb-class>
  |  <persistence-type>Container</persistence-type>
  |  <prim-key-class>java.lang.Long</prim-key-class>
  |  <primkey-field>id</primkey-field>
  |  <reentrant>False</reentrant>
  |  <cmp-field><field-name>id</field-name></cmp-field>
  |  <cmp-version>2.x</cmp-version>
  |  <abstract-schema-name>AdminRolesAPS</abstract-schema-name>
  |  <resource-ref>
  |   <res-ref-name>jdbc/mysql</res-ref-name>
  |   <res-type>javax.sql.DataSource</res-type>
  |   <res-auth>Container</res-auth>
  |  </resource-ref>    
  | </entity>
  | 

This works fine... and not an Unknown-pk in sight

View the original post : 
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3832261#3832261

Reply to the post : 
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3832261


-------------------------------------------------------
This SF.net email is sponsored by: The Robotic Monkeys at ThinkGeek
For a limited time only, get FREE Ground shipping on all orders of $35
or more. Hurry up and shop folks, this offer expires April 30th!
http://www.thinkgeek.com/freeshipping/?cpg=12297
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to