1 Reply Latest reply on Mar 23, 2005 9:34 AM by ilya liberman

    jboss-hibernate: who ate my exception?

    ilya liberman Newbie

      I am using jboss 4.0.1 with hibernate 2 to connect to Oracle9 with thing jdbc driver (ojdbc14.jar). My Hibernate code resides in a session bean and I access Hibernate sessions via jboss HibernateContext.getSession

      I am seeing a weird thing where some jdbc exceptions do *not* get propagated to the caller (me) via HibernateException or any other exception for that matter.

      Now, that's is not true for all exceptions. If I have a typo in the HQL query referencing non-existing entity, I get HibernateException that tells me all about it. So, that's cool.

      Troublesome bit is with another piece of code that violates a primary key constraint (as a test case). In that case i get no exception thrown, but information about the error appears happily in the log (as below). Needless to say the actual thing i tried accomplish (an insert in this case) fails, but my code thinks everything went fine.

      2005-03-22 14:53:59,497 DEBUG [net.sf.hibernate.impl.BatcherImpl] Executing batch size: 1
      2005-03-22 14:53:59,509 DEBUG [net.sf.hibernate.util.JDBCExceptionReporter] SQL Exception
      java.sql.BatchUpdateException: ORA-00001: unique constraint (PK) violated

      at oracle.jdbc.dbaccess.DBError.throwBatchUpdateException(DBError.java:\
      at oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePrepar\
      at org.jboss.resource.adapter.jdbc.WrappedStatement.executeBatch(Wrappe\
      at net.sf.hibernate.impl.BatchingBatcher.doExecuteBatch(BatchingBatcher\
      at net.sf.hibernate.impl.BatcherImpl.executeBatch(BatcherImpl.java:126)
      at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2421)
      at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2371)
      at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2240)
      at org.jboss.hibernate.session.TransactionSynch.beforeCompletion(TransactionSynch.java:55)

      What am I missing here ?

      - ilya.