1 Reply Latest reply on Oct 8, 2001 11:18 PM by davidjencks

    JBoss Entity Bean not compatible with Sybase identity column

    levent

      When trying to read from a sybase table which has got an identity cloumn, we got the following exception on the JBoss server ::::::::---------

      [EntitySynchronizationInterceptor] Store failed
      java.rmi.ServerException: Store failed; nested exception is:
      com.sybase.jdbc2.jdbc.SybSQLException: Illegal attempt to update identity field 'charset_id'.

      com.sybase.jdbc2.jdbc.SybSQLException: Illegal attempt to update identity field 'charset_id'.
      -------------------------------------------------------

      And the following exception on the client ::::--------
      java.lang.reflect.UndeclaredThrowableException: javax.transaction.RollbackException: Unable to commit, tx=XidImpl [FormatId=257, GlobalId=wsfr0105//3, BranchQual=] status=STATUS_ROLLEDBACK
      ------------------------------------------------------

      Seting standardjaws tuned-updates to true doesn't solve the Problem. After that we are still not able to invoke create Method.


      Many thanks

        • 1. Re: JBoss Entity Bean not compatible with Sybase identity co
          davidjencks

          You can't use fields set by the db on insert with jboss. There is no way for jboss to find the new values (at least no implemented way). You have to find some way to have your bean find the pk value before it inserts the row. There are hundreds of posts arguing about the best way to get such a value, suggesting such arcane procedures as using a random number and retrying on failure, constructing a guid from the server id and the time, etc etc. Personally I like the idea of having an mbean that gets the next id from the database, and your bean gets the id from the mbean. If you have something like sequences with configurable step size, you can set the step fairly large and avoid some db access (hand out the ones in between steps yourself). With identity columns, you will probably need a separate table with just the identity: insert and read, then delete, or write a stored procedure to do this.