This content has been marked as final.
Show 1 reply
-
1. Re: EntiyBean and auto-increment
tterm Mar 17, 2006 10:43 AM (in response to modendahl)Hello,
this is a possible solution for me:/** * @ejb.bean name="Example" * display-name="Name for Example" * description="Description for Example" * jndi-name="ejb/Example" * type="CMP" * cmp-version="2.x" * view-type="local" * primkey-field = "autoIncField" * * @ejb.pk class = "java.lang.Integer" generate = "false" * * @jboss.unknown-pk class = "java.lang.Integer" * column-name = "autoIncField" * jdbc-type = "INTEGER" * sql-type = "INTEGER" * auto-increment = "true" * * * @jboss.entity-command name = "mysql-get-generated-keys" * class = "org.jboss.ejb.plugins.cmp.jdbc.keygen.JDBCMySQLCreateCommand" * */ public abstract class ExampleBean implements EntityBean { // more methods /** * Getter for CMP Field autoIncField * * @ejb.pk-field * @ejb.persistent-field * @ejb.interface-method view-type="local" * * @jboss.persistence auto-increment = "true" * */ public abstract java.lang.Integer getAutoIncField(); /** * Setter for CMP Field autoIncField * * * @ejb.interface-method view-type="local" */ public abstract void setAutoIncField(java.lang.Integer value); }
This works for me.
How would you access a row in a table with a generated PK with a simple sql statement if you don't have the key value. I guess you have some other data in the row for a search criteria. I hope you know what I mean.
Thomas