I'm using MySQL with a table using an Integer PK field with the autoincrement attribute on. In this code the PK is available after the ejbCreate method because of the <entity-command name="mysql-get-generated-keys"/> and <auto-increment/> elements. I'm using XDoclet partly, only for generating the interfaces.
Johan. The bean class | import javax.ejb.*; | | /** | * @ejb.bean | * name = "Archive" | * type = "CMP" | * view-type = "local" | * local-jndi-name = "nl/blabla/ArchiveLocal" | * @ejb.pk | * class = "java.lang.Integer" | * generate = "false" | * @ejb.finder | * signature = "java.util.Collection findAll()" | * query = "" | */ | public abstract class ArchiveBean implements EntityBean { | | private EntityContext entityContext; | | /** | * @ejb.create-method | */ | public Integer ejbCreate(String code, String description) throws CreateException { | setCode(code); | setDescription(description); | return null; | } | public void ejbPostCreate(String code, String description) { | } | public void ejbActivate() { | } | public void ejbPassivate() { | } | public void ejbLoad() { | } | public void ejbRemove() { | } | public void ejbStore() { | } | public void setEntityContext(EntityContext entityContext) { | this.entityContext = entityContext; | } | public void unsetEntityContext() { | entityContext = null; | } | | /** | * @ejb.interface-method | */ | public abstract Integer getKey(); | public abstract void setKey(Integer key); | | /** | * @ejb.interface-method | */ | public abstract String getCode(); | public abstract void setCode(String code); | | /** | * @ejb.interface-method | */ | public abstract String getDescription(); | public abstract void setDescription(String description); | } | The ejb-jar.xml | <!-- Entity Beans --> | <entity > | <ejb-name>Archive</ejb-name> | <local-home>nl.blabla.ArchiveLocalHome</local-home> | <local>nl.blabla.ArchiveLocal</local> | <ejb-class>nl.blabla.ArchiveBean</ejb-class> | <persistence-type>Container</persistence-type> | <prim-key-class>java.lang.Integer</prim-key-class> | <reentrant>False</reentrant> | <cmp-version>2.x</cmp-version> | <abstract-schema-name>Archive</abstract-schema-name> | <cmp-field > | <field-name>key</field-name> | </cmp-field> | <cmp-field > | <field-name>code</field-name> | </cmp-field> | <cmp-field > | <field-name>description</field-name> | </cmp-field> | <primkey-field>key</primkey-field> | <query> | <query-method> | <method-name>findAll</method-name> | <method-params> | </method-params> | </query-method> | <ejb-ql>SELECT OBJECT(a) FROM Archive AS a</ejb-ql> | </query> | </entity> | The jbosscmp-jdbc.xml | <jbosscmp-jdbc> | <defaults> | <datasource>java:/mysql-localhost-pop</datasource> | <datasource-mapping>mySQL</datasource-mapping> | <create-table>false</create-table> | <entity-command name="mysql-get-generated-keys"/> | </defaults> | | <enterprise-beans> | | <entity> | <ejb-name>Archive</ejb-name> | <table-name>t_archive</table-name> | <cmp-field> | <field-name>key</field-name> | <column-name>arc_seq</column-name> | <auto-increment/> | </cmp-field> | <cmp-field> | <field-name>code</field-name> | <column-name>arc_code</column-name> | </cmp-field> | <cmp-field> | <field-name>description</field-name> | <column-name>arc_description</column-name> | </cmp-field> | </entity> | View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3855513#3855513 Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3855513 ------------------------------------------------------- This SF.Net email is sponsored by: InterSystems CACHE FREE OODBMS DOWNLOAD - A multidimensional database that combines robust object and relational technologies, making it a perfect match for Java, C++,COM, XML, ODBC and JDBC. www.intersystems.com/match8 _______________________________________________ JBoss-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-user