1 Reply Latest reply on Jul 10, 2008 6:21 PM by stanton fisque

    persist entity ignores the

    stanton fisque Newbie

      i'm having an issue with:

      JBoss 4.2.2-GA
      Oracle 10g ( 10.2.0.2 - Solaris )

      i have a bean that has an attribute:

      @Id
      @Column( name= "TAXONOMY_DETAIL", nullable = false )
      private String taxonomyDetail;

      when i go to persist an object of this type, the i get a slew of exceptions in the server.log with that appear to say that the persistence layer is using the attribute name as the column name and ignoring the "name" specified in the @Column annotation:

      [paste]
      Caused by: javax.transaction.RollbackException: [com.arjuna.ats.internal.jta.transaction.arjunacore.commitwhenaborted] [com.arjuna.ats.internal.jta.transaction.arjunacore.commitwhenaborted] Can't commit because the transaction is in aborted state
      at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.commitAndDisassociate(TransactionImple.java:1401)
      at com.arjuna.ats.internal.jta.transaction.arjunacore.BaseTransaction.commit(BaseTransaction.java:135)
      at com.arjuna.ats.jbossatx.BaseTransactionManagerDelegate.commit(BaseTransactionManagerDelegate.java:87)
      at org.jboss.aspects.tx.TxPolicy.endTransaction(TxPolicy.java:175)
      ... 40 more
      Caused by: javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update
      at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:637)
      at org.hibernate.ejb.AbstractEntityManagerImpl$1.beforeCompletion(AbstractEntityManagerImpl.java:532)
      at com.arjuna.ats.internal.jta.resources.arjunacore.SynchronizationImple.beforeCompletion(SynchronizationImple.java:114)
      at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.beforeCompletion(TwoPhaseCoordinator.java:247)
      at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.end(TwoPhaseCoordinator.java:86)
      at com.arjuna.ats.arjuna.AtomicAction.commit(AtomicAction.java:177)
      at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.commitAndDisassociate(TransactionImple.java:1389)
      ... 43 more
      Caused by: org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update
      at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)
      at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
      at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:253)
      at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:266) at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:167) at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
      at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
      at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
      at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
      at org.hibernate.ejb.AbstractEntityManagerImpl$1.beforeCompletion(AbstractEntityManagerImpl.java:523)
      ... 48 more
      Caused by: java.sql.BatchUpdateException: ORA-00904: "TAXONOMYDETAIL": invalid identifier

      at oracle.jdbc.driver.DatabaseError.throwBatchUpdateException(DatabaseError.java:343)
      at oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatement.java:10698)
      at org.jboss.resource.adapter.jdbc.WrappedStatement.executeBatch(WrappedStatement.java:519)
      at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)
      at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:246)
      ... 55 more

      [end paste]

      i am at a loss as to why the "name" parameter of the @Column annotation would be ignored.

      == stanton

        • 1. Re: persist entity ignores the
          stanton fisque Newbie

          posting this so that anyone else searching on this will find what i found:

          if you have an object with a composite key object, e.g:

          @Entity
          @IdClass( ThingPK.class )
          @Table( name="Thing" )
          public class Thing
          implements Serializable
          {
           @Id
           private String keyOne;
          
           @Id
           private String keyTwo;
          
           @Column( name="value_one" )
           private String valueOne;
          
           // getter/setters omitted for brevity
          }
          
          public class ThingPK
          implements Serializable
          {
           @Column( name="key_one" )
           private String keyOne;
          
           @Column( name="key_two" )
           private String keyTwo;
          
           // getter/setters omitted for brevity
          }
          


          what ended up causing the above problem is that i had annotated the @Columns in the entity object (Thing), instead of instrumenting the PK class (ThingPK), once i corrected it (to appear like the above), the column name was properly injected and it worked fine. all of the example code i've seen never indicates that the @Column instrumentation is supposed to go into the PK class and not the entity class.

          caveat emptor.

          == stanton