-
1. Re: non-null object results in 'null-object' lock exception
adrian.brock Jun 4, 2003 9:29 AM (in response to hqic)You haven't mapped your primary key correctly,
you are probably using an auto-increment
in the db. You need to tell jboss this.
Use search in the CMP forum.
Regards,
Adrian -
2. Re: non-null object results in 'null-object' lock exception
hqic Jun 4, 2003 2:33 PM (in response to hqic)Adrian,
Thanks for setting me on the right track... you were exactly right, I was using MySQL's auto-increment on the primary key field and that was confusing JBoss. Here is the solution. I modified jbosscmp-jdbc.xml for the entity bean in question as follows:
<jbosscmp-jdbc>
<enterprise-beans>
...
<!-- added the following to handle auto-incement pk -->
<unknown-pk>
<unknown-pk-class>java.lang.Integer</unknown-pk-class>
<field-name>id</field-name>
<column-name>id</column-name>
<jdbc-type>INTEGER</jdbc-type>
<sql-type>INT(11)</sql-type>
<auto-increment/>
</unknown-pk>
<entity-command name="mysql-get-generated-keys"/>
<!-- end of handling auto-increment pk -->
...
</enterprise-beans>
</jbosscmp-jdbc>
There is a more complete discusson of this at:
http://www.kylev.com/projects/jboss/cmpauto.html
Mike.