2 Replies Latest reply on Oct 19, 2002 10:06 AM by Jeremy Cowgar

    How do I implement a db sequence with CMP for the primary ke

    da_alchemist Newbie

      Hello all,

      I am using JBoss 3.0.0 and have created an Entity bean, called PersonEJB, with CMP 2.0. My question is how do I implement a sequence (common in most databases) for the primary key field in MySQL 3.23.51 (or any other database for that matter)? The primary key field is a single field (as opposed to a composite) of type java.lang.Integer. Is there a way to specify an AUTO_INCREMENT column on the primary key field within XDoclet for the EJB QL or JBossQL? Or, are there more common ways of implementing sequences on primary key fields with CMP 2.0? Please help.

      Here are my XDoclet tags:

      /**
      * @ejb:bean name="stock/Person" type="CMP" local-jndi-name="ejb/stock/Person"
      * view-type="local" reentrant="false" cmp-version="2.x"
      * @jboss:table-name "person"
      * @jboss:create-table "true"
      * @jboss:remove-table "true"
      * @jboss:tuned-updates "true"
      * @jboss:read-only "false"
      */

      public abstract class PersonEJB implements EntityBean, java.io.Serializable

      ...

      /**
      * @ejb:pk-field
      * @ejb:interface-method view-type="local"
      * @ejb:persistent-field
      * @ejb:transaction type="Supports"
      * @ejb:permission role-name="user"
      * @ejb:permission role-name="admin"
      */
      public java.lang.Integer getId ()
      {
      return null;
      }

      ...

      } // end of PersonEJB

      Thanks.