1 Reply Latest reply on Apr 18, 2006 7:21 PM by J Chau

    ejb3.0 and IDENTITY Generated ID problem

    J Chau Newbie

      I'm using IDENTITY generated Ids. This is for a serial (autoincrement) datatype on the new Informix 10.0 server. I'm getting an error in which ejb cannot return the incremented Id value as evidenced by the error below. Using a previous version of Informix 9.4, it used to work. After it inserts a row, it goes on to do a sql statement specific to informix in which it gets the last autoincremented Id back and puts it into the entity bean. Now, the new version, it doesn't even get to that sql statement anymore, it just dies after it executes the insert statement and rolls back the whole transaction. I called informix and I am using the jdbc driver which is certificated for informix 9.4 and 10. Obviously, there's some difference in the way the two servers behave because it works in one but not the other, but does anybody have any information in which can help me fix this issue myself? Any clues?



      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      @Column(name=DatabaseConstants.USER_COLUMN_ID)
      public Integer getId() {
      return id;
      }



      14:54:28,946 INFO [STDOUT] Hibernate: insert into skxshop_user (password, email, registration_date, last_login_date, ca
      ncelled, store_id, banned, zip, password_exp_date) values (?, ?, ?, ?, ?, ?, ?, ?, ?)
      14:54:28,993 WARN [RequestProcessor] Unhandled Exception thrown: class javax.ejb.EJBException
      14:54:28,993 ERROR [[action]] Servlet.service() for servlet action threw exception
      javax.ejb.EJBException: javax.persistence.PersistenceException: org.hibernate.HibernateException: The database returned
      no natively generated identity value
      at org.jboss.ejb3.tx.Ejb3TxPolicy.handleExceptionInOurTx(Ejb3TxPolicy.java:69)
      at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:83)
      at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:192)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
      at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
      at org.jboss.ejb3.stateful.StatefulInstanceInterceptor.invoke(StatefulInstanceInterceptor.java:81)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
      at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:78)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
      at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:47)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
      at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
      at org.jboss.ejb3.stateful.StatefulContainer.dynamicInvoke(StatefulContainer.java:308)
      at org.jboss.ejb3.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:55)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)

        • 1. Re: ejb3.0 and IDENTITY Generated ID problem
          J Chau Newbie

          more specifically from the DEBUG. It looks like i'm losing the transaction. Below is the problem for the bad database, and below that is the good database (one that works).


          2006-04-18 15:28:32,355 INFO [STDOUT] ************ gettting id: null
          2006-04-18 15:28:32,371 DEBUG [org.hibernate.event.def.AbstractSaveEventListener] executing identity-insert immediately
          2006-04-18 15:28:32,371 DEBUG [org.hibernate.jdbc.AbstractBatcher] about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
          2006-04-18 15:28:32,371 DEBUG [org.hibernate.jdbc.ConnectionManager] opening JDBC connection
          2006-04-18 15:28:32,371 DEBUG [org.hibernate.SQL] insert into skxshop_user (password, email, registration_date, last_login_date, cancelled, store_id, banned, zip, password_exp_date) values (?, ?, ?, ?, ?, ?, ?, ?, ?)
          2006-04-18 15:28:32,371 INFO [STDOUT] Hibernate: insert into skxshop_user (password, email, registration_date, last_login_date, cancelled, store_id, banned, zip, password_exp_date) values (?, ?, ?, ?, ?, ?, ?, ?, ?)
          2006-04-18 15:28:32,402 DEBUG [org.hibernate.jdbc.AbstractBatcher] about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
          2006-04-18 15:28:32,402 DEBUG [org.hibernate.jdbc.ConnectionManager] aggressively releasing JDBC connection
          2006-04-18 15:28:32,402 DEBUG [org.hibernate.jdbc.ConnectionManager] releasing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]
          2006-04-18 15:28:32,402 DEBUG [org.hibernate.jdbc.JDBCContext] TransactionFactory reported no active transaction; Synchronization not registered
          2006-04-18 15:28:32,402 DEBUG [org.hibernate.jdbc.JDBCContext] TransactionFactory reported no active transaction; Synchronization not registered
          2006-04-18 15:28:32,402 DEBUG [org.jboss.ejb3.entity.ManagedEntityManagerFactory] ************** closing entity managersession **************
          2006-04-18 15:28:32,402 DEBUG [org.hibernate.jdbc.JDBCContext] TransactionFactory reported no active transaction; Synchronization not registered
          2006-04-18 15:28:32,402 DEBUG [org.apache.struts.util.PropertyMessageResources] getMessage(en_US,unhandledException)





          2006-04-18 15:41:49,459 INFO [STDOUT] ************ gettting id: null
          2006-04-18 15:41:49,475 DEBUG [org.hibernate.event.def.AbstractSaveEventListener] executing identity-insert immediately
          2006-04-18 15:41:49,475 DEBUG [org.hibernate.jdbc.AbstractBatcher] about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
          2006-04-18 15:41:49,475 DEBUG [org.hibernate.jdbc.ConnectionManager] opening JDBC connection
          2006-04-18 15:41:49,475 DEBUG [org.hibernate.SQL] insert into skxshop_user (password, email, registration_date, last_login_date, cancelled, store_id, banned, zip, password_exp_date) values (?, ?, ?, ?, ?, ?, ?, ?, ?)
          2006-04-18 15:41:49,475 INFO [STDOUT] Hibernate: insert into skxshop_user (password, email, registration_date, last_login_date, cancelled, store_id, banned, zip, password_exp_date) values (?, ?, ?, ?, ?, ?, ?, ?, ?)
          2006-04-18 15:41:49,537 DEBUG [org.hibernate.jdbc.AbstractBatcher] about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
          2006-04-18 15:41:49,537 DEBUG [org.hibernate.jdbc.ConnectionManager] aggressively releasing JDBC connection
          2006-04-18 15:41:49,537 DEBUG [org.hibernate.jdbc.ConnectionManager] releasing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]
          2006-04-18 15:41:49,537 DEBUG [org.hibernate.jdbc.AbstractBatcher] about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
          2006-04-18 15:41:49,537 DEBUG [org.hibernate.jdbc.ConnectionManager] opening JDBC connection
          2006-04-18 15:41:49,537 DEBUG [org.hibernate.SQL] select dbinfo('sqlca.sqlerrd1') from systables where tabid=1
          2006-04-18 15:41:49,537 INFO [STDOUT] Hibernate: select dbinfo('sqlca.sqlerrd1') from systables where tabid=1
          2006-04-18 15:41:49,537 DEBUG [org.hibernate.id.IdentifierGeneratorFactory] Natively generated identity: 1
          2006-04-18 15:41:49,537 DEBUG [org.hibernate.jdbc.AbstractBatcher] about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
          2006-04-18 15:41:49,553 DEBUG [org.hibernate.jdbc.ConnectionManager] aggressively releasing JDBC connection
          2006-04-18 15:41:49,553 DEBUG [org.hibernate.jdbc.ConnectionManager] releasing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]
          2006-04-18 15:41:49,553 DEBUG [org.hibernate.jdbc.AbstractBatcher] about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
          2006-04-18 15:41:49,553 DEBUG [org.hibernate.jdbc.ConnectionManager] opening JDBC connection
          2006-04-18 15:41:49,553 DEBUG [org.hibernate.SQL] insert into skxshop_user_profile (opt_in, gender, first_name, last_name, birth_year, birth_month, birth_day, last_purc_date, user_id) values (?, ?, ?, ?, ?, ?, ?, ?, ?)
          2006-04-18 15:41:49,553 INFO [STDOUT] Hibernate: insert into skxshop_user_profile (opt_in, gender, first_name, last_name, birth_year, birth_month, birth_day, last_purc_date, user_id) values (?, ?, ?, ?, ?, ?, ?, ?, ?)
          2006-04-18 15:41:49,569 DEBUG [org.hibernate.jdbc.AbstractBatcher] about to close PreparedStatement (open PreparedStatements: 1, globally: 1)