Announcement Announcement Module
No announcement yet.
DataIntegrityViolationException w/ hsqldb+hibernate Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • DataIntegrityViolationException w/ hsqldb+hibernate

    I am using spring with hibernate and hsqldb. I have code which creates a new user in the DB. There is a unique constraint on the username property, but when it is violated, hsqldb returns an error code of 0, which spring translates to a UncategorizedSQLException. This only happens when it is executed in a batch and when using hibernate, it seems that everything is always executed in a batch. This doesn't happen with MySql, it correctly throws DataIntegrityViolationException. Have others noticed this problem? Is this an hsqldb bug?

  • #2
    What hsqldb are you using?
    Using hsqldb 1.7.2 should get a SQLState '23000' and errorCode '-104'. Spring will then throw org.springframework.dao.DataIntegrityViolationExce ption



    • #3
      Hi, could you solve this problem?
      I am using spring 1.2.3 with hibernate 3.0.5 and hsqldb My problem occurs when I try to delete a row being referenced by another one. I get an UncategorizedSQLException and not a DataIntegrityViolationException.
      This error appears when using the batch update feature of the jdbc2 hsql driver.
      This is the stacktrace I'm getting:
      org.springframework.jdbc.UncategorizedSQLException: Hibernate transaction synchronization; uncategorized SQLException for SQL [delete from CURRENCY where ISO_CODE=?]; SQL state [null]; error code [0]; failed batch; nested exception is java.sql.BatchUpdateException: failed batch
      java.sql.BatchUpdateException: failed batch
      	at org.hsqldb.jdbc.jdbcStatement.executeBatch(Unknown Source)
      	at org.hsqldb.jdbc.jdbcPreparedStatement.executeBatch(Unknown Source)
      	at org.apache.commons.dbcp.DelegatingStatement.executeBatch(
      	at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(
      	at org.hibernate.jdbc.AbstractBatcher.executeBatch(
      	at org.hibernate.engine.ActionQueue.executeActions(
      	at org.hibernate.engine.ActionQueue.executeActions(
      	at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(
      	at org.hibernate.event.def.DefaultFlushEventListener.onFlush(
      	at org.hibernate.impl.SessionImpl.flush(
      	at org.springframework.orm.hibernate3.SessionFactoryUtils$SpringSessionSynchronization.beforeCommit(
      	at org.springframework.transaction.interceptor.TransactionAspectSupport.doCommitTransactionAfterReturning(
      	at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(
      	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(
      	at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(
      	at com.lumina.silver.application.BajaCurrency$$EnhancerByCGLIB$$2facbb18.Ok(<generated>)
      	at com.lumina.silver.BajaCurrencyTest.testBajaConOrdenesReferentes(
      Is this an HSQLDB issue?

      Juan Manuel
      Last edited by juanmanuel32; Dec 2nd, 2005, 02:18 PM.