2 Replies Latest reply on May 14, 2005 9:13 AM by Gioele Barabucci

    autogenerated pk with hypersonic

    Gioele Barabucci Newbie

      I'd like to have an autogenerated pk but jboss 3.2.5 refuses to create this EJB.

      This is the EJB I created (I kept only the interesting xdoclet tags):

      /**
       * @ejb.bean name="StudentGroup"
       * local-jndi-name="ejb/StudentGroup"
       * type="CMP"
       * cmp-version="2.x"
       * primkey-field="id"
       * @jboss.persistence pk-constraint="false"
       * @jboss.entity-command name="hsqldb-fetch-key"
       */
      public abstract class StudentGroupBean implements EntityBean {
      
       /**
       * @ejb.create-method view-type = "local"
       */
       public Integer ejbCreate(String password)
       throws javax.ejb.CreateException {
       setPassword(password);
       return null;
       }
      
       /**
       * @ejb.persistent-field
       * @jboss.persistence auto-increment="true"
       */
       public abstract Integer getId();
      
       ...


      The table is created, by jboss, with this command
      CREATE TABLE STUDENTGROUP (id INTEGER NOT NULL, password VARCHAR(256), article VARCHAR(256),
      CONSTRAINT PK_STUDENTGROUP PRIMARY KEY (id))


      CONSTRAINT... why? I used pk-constraint="false"


      When I try to add a new StudentGroup, I get
      19:00:03,909 ERROR [StudentGroup] Could not create entity
      java.sql.SQLException: Try to insert null into a non-nullable column in statement
      [INSERT INTO STUDENTGROUP (id, password, article) VALUES (NULL, 'pw', NULL)]


      why the first NULL? shouldn't jboss place the value returned by the DB in the pk?