0 Replies Latest reply on Nov 8, 2002 12:57 AM by gateway87

    null primary key??

    gateway87 Newbie

      Hi,

      I created a User_Info CMP with middlegen and xdoclet and also write a stateless session bean to process this CMP. Then I write a servlet to access this session bean.

      Some actions, like findByPrimaryKey, delete, getAll, can work well. However, only the insert action throw following exception:

      2002-11-08 11:28:19,328 DEBUG [com.jianhong.user.ejb.UserManagerBean] User to be created: {id=10 username=aaa password=bbb}
      2002-11-08 11:28:19,328 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCCreateEntityCommand.UserInfo] Create: pk=null
      2002-11-08 11:28:19,328 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCCreateEntityCommand.UserInfo] Executing SQL: SELECT COUNT(*) FROM USER_INFO WHERE ID=?
      2002-11-08 11:28:19,328 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCCreateEntityCommand.UserInfo] Executing SQL: INSERT INTO USER_INFO (ID, USERNAME, PASSWORD) VALUES (?, ?, ?)
      2002-11-08 11:28:19,359 ERROR [org.jboss.ejb.plugins.cmp.jdbc.JDBCCreateEntityCommand.UserInfo] Could not create entity
      java.sql.SQLException: ORA-01400: cannot insert NULL into ("SYSTEM"."USER_INFO"."ID")

      at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:168)
      at oracle.jdbc.oci8.OCIDBAccess.check_error(OCIDBAccess.java:1597)
      .......

      I use jboss3.03 and tomcat 4.1.x and Oracle 8i. I'm very appreciated for your help. The following is the code used to insert a user_info:

      public void createUser(UserInfoData user)
      throws Exception
      {
      UserInfoLocalHome userLocalHome = UserInfoUtil.getLocalHome();
      System.out.println("UserInfoLocal is " +
      (userLocalHome == null ? "NULL" : "NOT null"));
      mLog.debug("User to be created: " + user);
      userLocalHome.create(user);
      mLog.debug("User is created successfully.");
      }


      Gateway