Announcement Announcement Module
Collapse
No announcement yet.
DataIntegrityViolationException w/ hsqldb+hibernate Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • 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

    HTH

    Comment


    • #3
      Hi, could you solve this problem?
      I am using spring 1.2.3 with hibernate 3.0.5 and hsqldb 1.8.0.2. 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:
      Code:
      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(DelegatingStatement.java:294)
      	at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:57)
      	at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:174)
      	at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:226)
      	at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:141)
      	at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:274)
      	at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
      	at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:730)
      	at org.springframework.orm.hibernate3.SessionFactoryUtils$SpringSessionSynchronization.beforeCommit(SessionFactoryUtils.java:875)
      	at org.springframework.transaction.support.AbstractPlatformTransactionManager.triggerBeforeCommit(AbstractPlatformTransactionManager.java:656)
      	at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:481)
      	at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:468)
      	at org.springframework.transaction.interceptor.TransactionAspectSupport.doCommitTransactionAfterReturning(TransactionAspectSupport.java:258)
      	at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
      	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:144)
      	at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:606)
      	at com.lumina.silver.application.BajaCurrency$$EnhancerByCGLIB$$2facbb18.Ok(<generated>)
      	at com.lumina.silver.BajaCurrencyTest.testBajaConOrdenesReferentes(BajaCurrencyTest.java:63)
      Is this an HSQLDB issue?

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

      Comment

      Working...
      X