Make sure your in jbosscmp-jdbc.xml contains:
<unknown-pk> <unknown-pk-class>java.lang.Integer</unknown-pk-class> <auto-increment/> </unknown-pk> <entity-command name="mysql-get-generated-keys" class="org.jboss.ejb.plugins.cmp.jdbc.keygen.JDBCMySQLCreateCommand"/>
Thanks milowe - really appreciate the help - it works find now, you're a star.
Any recommendations of books that might help with the issues that arise between MySQL and JBoss ? Books on either subject don't really cover this area where the two meet.
btw. when the books refer to jbosscmp-jdbc.xml I've been assuming this is actually standardjbosscmp-jdbc.xml in the conf directory, or should I not be editing standardjbosscmp-jdbc.xml with this sort of thing ?
I dont know of any books focusing in integration MySQL and JBoss, but I am sure they are out there. Reading the manuals of MySQL and JBoss will get you far though. The fun part is then to figure out how to get it to work :) There is no magic about MySQL, it is used like all other data source in JBoss The file standardjbosscmp-jdbc.xml holds definition for the default data source and type mappings between Java, JDBC and the SQL servers being used. This is a server config file. Your deployment specific CMP<->MySQL mappings go into jbosscmp-jdbc.xml in your deployment archive. Preferably you use xdoclet to generate the jbosscmp-jdbc.xml file for you, it makes it a lot easier.
? * @jboss.persistence * datasource = "java:/MySqlDS" * datasource-mapping = "mySQL" * pk-constraint = "true" * * @jboss.unknown-pk * class="java.lang.Integer" * auto-increment="true" * * @jboss.entity-command * name="mysql-get-generated-keys" * class="org.jboss.ejb.plugins.cmp.jdbc.keygen.JDBCMySQLCreateCommand" ?
I think my problem is similar to yours. But I am using CMR in addition.
The primary key generation works fine when I done use relationships.
Can you help me out by viewing the post which describes the issue.
Could somebody please post the full contents of the jbosscmp-jdbc.xml and ejb-jar.xml files that contain an example of how to use an identity column as a primary key in an entity bean? Also would you please post the script that was used to create the table? I am trying to do this with a table in mssql and have had no luck so far.