-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Error when runing tests with HSQL-DB ?
PostPosted: Thu Oct 22, 2009 10:53 pm 
Newbie

Joined: Thu Oct 22, 2009 9:39 pm
Posts: 2
Greetings all,

I use Spring +Hibernate to develop my project.My DAO/Service tests ran well until I switched my database from MySQL to HSQL .

I get the following error with HSQL :

Code:
Running com.bigg.platform.identity.service.IdentityMgmtServiceTest
INFO  23-10 10:34:56,203 (AbstractTransactionalSpringContextTests.java:startNewTransaction:323)  -Began transaction (1): transaction manager [org.springframework.orm.hibernate3.HibernateTransactionManager@b955970]; default rollback = true
Hibernate: select this_.role_id as role1_2_0_, this_.name as name2_0_ from identity_role this_ where this_.name like ?
Hibernate: insert into identity_role (role_id, name) values (null, ?)
Hibernate: call identity()
INFO  23-10 10:34:56,206 (AbstractTransactionalSpringContextTests.java:endTransaction:290)  -Rolled back transaction after test execution
INFO  23-10 10:34:56,207 (AbstractTransactionalSpringContextTests.java:startNewTransaction:323)  -Began transaction (1): transaction manager [org.springframework.orm.hibernate3.HibernateTransactionManager@b955970]; default rollback = true
Hibernate: select this_.role_id as role1_2_0_, this_.name as name2_0_ from identity_role this_ where this_.name like ?
Hibernate: insert into identity_secretq (question_id, question, answer) values (null, ?, ?)
Hibernate: call identity()
Hibernate: insert into identity_principal (principal_id, name, email, login_id, password, curr_status, reg_date, exp_date, login_date, question_id) values (null, ?, ?, ?, ?, ?, ?, ?, ?, ?)
Hibernate: call identity()
Hibernate: insert into identity_proles (principal_id, role_id) values (?, ?)
WARN  23-10 10:34:56,219 (JDBCExceptionReporter.java:logExceptions:77)  -SQL Error: 0, SQLState: null
ERROR 23-10 10:34:56,220 (JDBCExceptionReporter.java:logExceptions:78)  -failed batch
ERROR 23-10 10:34:56,221 (AbstractFlushingEventListener.java:performExecutions:301)  -Could not synchronize database state with session
org.hibernate.exception.GenericJDBCException: Could not execute JDBC batch update
   at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103)
   at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91)
   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:237)
   at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:145)
   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 com.bigg.platform.identity.service.IdentityMgmtServiceTest.flushHibernate(IdentityMgmtServiceTest.java:94)
   at com.bigg.platform.identity.service.IdentityMgmtServiceTest.testCreateUser(IdentityMgmtServiceTest.java:63)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:597)
   at junit.framework.TestCase.runTest(TestCase.java:154)
   at junit.framework.TestCase.runBare(TestCase.java:127)
   at org.springframework.test.ConditionalTestCase.runBare(ConditionalTestCase.java:69)
   at junit.framework.TestResult$1.protect(TestResult.java:106)
   at junit.framework.TestResult.runProtected(TestResult.java:124)
   at junit.framework.TestResult.run(TestResult.java:109)
   at junit.framework.TestCase.run(TestCase.java:118)
   at junit.framework.TestSuite.runTest(TestSuite.java:208)
   at junit.framework.TestSuite.run(TestSuite.java:203)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:597)
   at org.apache.maven.surefire.junit.JUnitTestSet.execute(JUnitTestSet.java:213)
   at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:140)
   at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:127)
   at org.apache.maven.surefire.Surefire.run(Surefire.java:177)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:597)
   at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:338)
   at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:997)
Caused by: 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:48)
   at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:246)
   ... 34 more
INFO  23-10 10:34:56,226 (AbstractTransactionalSpringContextTests.java:endTransaction:290)  -Rolled back transaction after test execution
Tests run: 2, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.04 sec <<< FAILURE!
Running com.bigg.platform.identity.service.SpringSecurityTest
INFO  23-10 10:34:56,244 (AbstractTransactionalSpringContextTests.java:startNewTransaction:323)  -Began transaction (1): transaction manager [org.springframework.orm.hibernate3.HibernateTransactionManager@b955970]; default rollback = true
Hibernate: select this_.role_id as role1_2_0_, this_.name as name2_0_ from identity_role this_ where this_.name like ?
Hibernate: insert into identity_secretq (question_id, question, answer) values (null, ?, ?)
Hibernate: call identity()
Hibernate: insert into identity_principal (principal_id, name, email, login_id, password, curr_status, reg_date, exp_date, login_date, question_id) values (null, ?, ?, ?, ?, ?, ?, ?, ?, ?)
Hibernate: call identity()
Hibernate: insert into identity_proles (principal_id, role_id) values (?, ?)
WARN  23-10 10:34:56,248 (JDBCExceptionReporter.java:logExceptions:77)  -SQL Error: 0, SQLState: null
ERROR 23-10 10:34:56,249 (JDBCExceptionReporter.java:logExceptions:78)  -failed batch
ERROR 23-10 10:34:56,249 (AbstractFlushingEventListener.java:performExecutions:301)  -Could not synchronize database state with session
org.hibernate.exception.GenericJDBCException: Could not execute JDBC batch update
   at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103)
   at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91)
   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:237)
   at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:145)
   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 com.bigg.platform.identity.service.SpringSecurityTest.flushHibernate(SpringSecurityTest.java:83)
   at com.bigg.platform.identity.service.SpringSecurityTest.testSpringSecurity(SpringSecurityTest.java:54)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:597)
   at junit.framework.TestCase.runTest(TestCase.java:154)
   at junit.framework.TestCase.runBare(TestCase.java:127)
   at org.springframework.test.ConditionalTestCase.runBare(ConditionalTestCase.java:69)
   at junit.framework.TestResult$1.protect(TestResult.java:106)
   at junit.framework.TestResult.runProtected(TestResult.java:124)
   at junit.framework.TestResult.run(TestResult.java:109)
   at junit.framework.TestCase.run(TestCase.java:118)
   at junit.framework.TestSuite.runTest(TestSuite.java:208)
   at junit.framework.TestSuite.run(TestSuite.java:203)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:597)
   at org.apache.maven.surefire.junit.JUnitTestSet.execute(JUnitTestSet.java:213)
   at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:140)
   at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:127)
   at org.apache.maven.surefire.Surefire.run(Surefire.java:177)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:597)
   at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:338)
   at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:997)
Caused by: 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:48)
   at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:246)
   ... 34 more
INFO  23-10 10:34:56,250 (AbstractTransactionalSpringContextTests.java:endTransaction:290)  -Rolled back transaction after test execution
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.023 sec <<< FAILURE!

Results :

Tests in error:
  testPrincipal(com.bigg.platform.identity.dao.PrincipalDAOTest)
  testCreateUser(com.bigg.platform.identity.service.IdentityMgmtServiceTest)
  testSpringSecurity(com.bigg.platform.identity.service.SpringSecurityTest)

Tests run: 8, Failures: 0, Errors: 3, Skipped: 0

INFO  23-10 10:34:56,261 (AbstractApplicationContext.java:doClose:696)  -Closing org.springframework.context.support.GenericApplicationContext@a94884d: display name [org.springframework.context.support.GenericApplicationContext@a94884d]; startup date [Fri Oct 23 10:34:54 JST 2009]; root of context hierarchy
INFO  23-10 10:34:56,262 (DefaultSingletonBeanRegistry.java:destroySingletons:282)  -Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@71060478: defining beans [identityRoleDAO,identityPrincipalDAO,identityMgmtService,identityNotificationService,identitySpringUserDetailService,javamailSender,adminNotBean,userNotBean,dataSource,sessionFactory,transactionManager]; root of factory hierarchy
INFO  23-10 10:34:56,262 (AbstractSessionFactoryBean.java:destroy:188)  -Closing Hibernate SessionFactory
INFO  23-10 10:34:56,262 (SessionFactoryImpl.java:close:769)  -closing
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] There are test failures.



My hibernate mapping file is :

Code:
<hibernate-mapping package="com.bigg.platform.identity.model">

   <!--  Class Principal -->
   <class name="Principal" table="identity_principal" lazy="false">
      <id type="long" name="id">
         <column name="principal_id" />
         <generator class="identity" />
      </id>
      
      <property name="name" type="string">
        <column name="name"/>      
      </property>
      
      <property name="email" type="string" not-null="true" unique-key="true" unique="true">
         <column name="email"/>
      </property>
      
      <property name="loginId" type="string" not-null="true" unique="true">
         <column name="login_id"/>
      </property>
      
      <property name="password" type="string" not-null="true">
         <column name="password"/>
      </property>
      
      <!--  Do not map logintype -since its depend on the system -->
<!--      <property name="loginType" column="login_type" type="com.bigg.platform.identity.dao.impl.LoginTypeMapping"/>-->
      <property name="status" column="curr_status" type="com.bigg.platform.identity.dao.impl.PrincipalStatusMapping"/>
      
      
      <!-- Dates -->
      <property name="registeredDate" type="timestamp">
        <column name="reg_date"/>
      </property>
      
      <property name="expireDate" type="timestamp">
       <column name="exp_date"/>
      </property>
      
      <property name="loginDate" type="timestamp">
       <column name="login_date"/>
      </property>
   

      <!-- unidirectional one-to-one -->
      <many-to-one name="secretQuestion" lazy="false" class="SecretQuestion" cascade="all">
         <column name="question_id" />
      </many-to-one>

      <!-- unidirectional many-to-many -->
      <set name="roles" table="identity_proles" cascade="save-update" lazy="false">
         <key column="principal_id" />
         <many-to-many column="role_id" class="Role" />
      </set>

   </class>

   <!-- Class Role -->
   <class name="Role" table="identity_role">
      <id type="long" name="id" >
         <column name="role_id" length="10485760" />
         <generator class="identity" />
      </id>
      <property name="name" type="string" not-null="true">
         <column name="name" />
      </property>
   </class>

   <!-- Class SecretQuestion -->
   <class name="SecretQuestion" table="identity_secretq">
      <id type="long" name="id">
         <column name="question_id" />
         <generator class="identity" />
      </id>
      <property name="question" type="string" not-null="true">
         <column name="question" />
      </property>
      <property name="answer" type="string" not-null="true">
         <column name="answer" />
      </property>

   </class>

</hibernate-mapping>


Top
 Profile  
 
 Post subject: Re: Error when runing tests with HSQL-DB ?
PostPosted: Mon Nov 02, 2009 11:34 am 
Newbie

Joined: Thu Feb 26, 2009 7:30 pm
Posts: 7
Did you ever solve this issue? I am having the same problem.


Top
 Profile  
 
 Post subject: Re: Error when runing tests with HSQL-DB ?
PostPosted: Thu Feb 09, 2012 12:17 pm 
Newbie

Joined: Fri Dec 03, 2010 1:03 pm
Posts: 4
The problem seems to be related to Spring's AbstractTransactionalSpringContextTests - somehow, it creates a HibernateTransactionManager bean but then it does not use it. I did not find the root cause yet though.

(Without a transaction manager JDBC is set to auto-commit, causing all kinds of weird problems)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.