I am trying to use the entity manager to store some entities to Hsql. The same code works well when connecting to oracle or mysql. But when I run my code agains hsql, hibernate complains. Since the code works fine agains other databases, I guessed that the problem is with my persistance.xml. Here is the listing:
Code:
persistance.xml
<?xml version="1.0" encoding="UTF-8"?>
<entity-manager>
<name>edf</name>
<class>com.mywells.edf.data.well.Well</class>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/>
<property name="hibernate.connection.driver_class" value="org.hsqldb.jdbcDriver"/>
<property name="hibernate.connection.username" value="sa"/>
<property name="hibernate.connection.password" value=""/>
<property name="hibernate.connection.url" value="jdbc:hsqldb:."/>
<property name="hibernate.max_fetch_depth" value="3"/>
<property name="hibernate.hbm2ddl.auto" value="create"/>
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.cache.provider_class" value="org.hibernate.cache.HashtableCacheProvider"/>
</properties>
</entity-manager>
The error I am getting:
Code:
Hibernate: select well0_.well_id_nbr as well1_0_0_, well0_.well_nme as well2_0_0_, well0_.well_type as well3_0_0_, well0_.well_category as well4_0_0_, well0_.well_result as well5_0_0_, well0_.well_oper_afe as well6_0_0_, well0_.well_api_nbr as well7_0_0_, well0_.well_unit_type as well8_0_0_, well0_.well_water_dpth as well9_0_0_, well0_.well_truck_flg as well10_0_0_, well0_.well_reentry_flg as well11_0_0_, well0_.well_spud_time as well12_0_0_, well0_.well_spud_date as well13_0_0_, well0_.well_surf_loc as well14_0_0_, well0_.well_offshore_flg as well15_0_0_, well0_.well_field_nme as well16_0_0_, well0_.well_div_nme as well17_0_0_, well0_.well_dist_nme as well18_0_0_, well0_.well_county_nme as well19_0_0_, well0_.well_country_nme as well20_0_0_ from wellinfo well0_ where well0_.well_id_nbr=?
Hibernate: insert into wellinfo (well_nme, well_type, well_category, well_result, well_oper_afe, well_api_nbr, well_unit_type, well_water_dpth, well_truck_flg, well_reentry_flg, well_spud_time, well_spud_date, well_surf_loc, well_offshore_flg, well_field_nme, well_div_nme, well_dist_nme, well_county_nme, well_country_nme, well_id_nbr) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
09:09:04,125 WARN JDBCExceptionReporter:71 - SQL Error: 0, SQLState: null
09:09:04,140 ERROR JDBCExceptionReporter:72 - failed batch
09:09:04,140 ERROR AbstractFlushingEventListener:299 - 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:91)
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:79)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:200)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:230)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:140)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:296)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:905)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:345)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
at org.hibernate.ejb.TransactionImpl.commit(TransactionImpl.java:36)
at com.mywells.edf.data.hibernate.HibernateRepository.persist(HibernateRepository.java:139)
at com.mywells.edf.data.hibernate.HibernateRepositoryTest.testFindClassOfTObject(HibernateRepositoryTest.java:41)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
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 org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
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.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:58)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:193)
... 25 more
Any suggestions?
thanks,
Khalid