2 Replies Latest reply on Jul 18, 2002 10:52 AM by Ben Wong

    Primary as Automatic PK

    Peter Newbie

      Hello,

      i have read that an EJB can auto generate his primarykey, i think that is the only correct way for using a database.

      when i take a normal attribute as PK i can not change this attribute and create self a PK is not so good :(.

      but the following idea will not use with JBoss :( (what does it wrong?)

      Idea:

      - EntityBean
      public Object ejbCreate(.....)
      {
      ...
      return null;
      }

      - BeanHome
      public findByPrimaryKey(Object primaryKey)

      - ejb-jar
      <prim-key-class>java.lang.Object</prim-key-class>



      error:

      20:45:56,153 ERROR [EjbModule] Starting failed
      org.jboss.deployment.DeploymentException: Error while creating table; - nested throwable: (java.sql.SQLException: Column not found: ) in stat
      ement [CREATE TABLE BENUTZER (login VARCHAR(256), passwort VARCHAR(256), type VARCHAR(256), timestamp DATE, status VARCHAR(256), CONSTRAINT P
      K_BENUTZER PRIMARY KEY ())])
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCStartCommand.createTable(JDBCStartCommand.java:190)



      thanks for help
      bye Peter