wood burning stoves 2.0*
The moose likes JBoss/WildFly and the fly likes Adding Statement.RETURN_GENERATED_KEYS in jbosscmp-jdbc.xml Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Products » JBoss/WildFly
Bookmark "Adding Statement.RETURN_GENERATED_KEYS in jbosscmp-jdbc.xml" Watch "Adding Statement.RETURN_GENERATED_KEYS in jbosscmp-jdbc.xml" New topic
Author

Adding Statement.RETURN_GENERATED_KEYS in jbosscmp-jdbc.xml

C Va
Greenhorn

Joined: Feb 25, 2013
Posts: 1
Hi.

I am using Xdoclet to generate an EJB. I am trying to migrate from mysql 4 to mysql 5 but I get an error:
Caused by: java.sql.SQLException: Generated keys not requested. You need to specify Statement.RETURN_GENERATED_KEYS to Statement.executeUpdate() or Connection.prepareStatement().

The question is, how can I specify Statement.RETURN_GENERATED_KEYS to JDBCMySQLCreateCommand?

My jbosscmp-jdbc.xml looks like this:

<entity>
<ejb-name>OwnerDataEJB</ejb-name>
<datasource>java:jdbc/controlMysqlDS</datasource>
<datasource-mapping>mySQL</datasource-mapping>
<create-table>false</create-table>
<remove-table>false</remove-table>
<read-only>false</read-only>
<table-name>control.ownerdata</table-name>
<cmp-field>
<field-name>tsInit</field-name>
<column-name>ts_init</column-name>

</cmp-field>

<unknown-pk>
<unknown-pk-class>java.lang.Long</unknown-pk-class>
<auto-increment/>
</unknown-pk>
<entity-command name="mysql-get-generated-keys" class="org.jboss.ejb.plugins.cmp.jdbc.keygen.JDBCMySQLCreateCommand">
<attribute name="class-name">com.mysql.jdbc.jdbc2.optional.PreparedStatementWrapper</attribute>
</entity-command>
</entity>

Thanks
 
Don't get me started about those stupid light bulbs.
 
subject: Adding Statement.RETURN_GENERATED_KEYS in jbosscmp-jdbc.xml
 
Similar Threads
Issue in CMR entity bean
CMP 2.0 problem with MySQL server
CMP beans not entering data in database
JBoss Primary Key Generation
Entity Bean on JBoss4.0.2