Hi,
I have an application, where I an entity with composite-id from 2 columns. When I create new instance of this class and do sess.saveOrUpdate() it saves it, but if I create another instance and try to do the same with it in the same thread, it fails with exception thrown: HibernateException: Batch update row count wrong: 0
Hibernate version: v2.1
Mapping documents:
<class
name="sample.EntityDa"
table="ENTITY"
dynamic-update="false"
dynamic-insert="false"
select-before-update="false"
optimistic-lock="version"
>
<composite-id
name="comp_id"
unsaved-value="none"
class="sample.EntityDaPK"
>
<key-property
name="prop1"
type="java.lang.String"
column="PROPERTY_1"
length="6"
/>
<key-property
name="prop2"
type="java.lang.String"
column="PROPERTY_2"
length="10"
/>
</composite-id>
<property
name="prop3"
type="java.lang.String"
update="false"
insert="false"
access="property"
column="PROPERTY_3"
length="6"
/>
Code between sessionFactory.openSession() and session.close():
tx = sess.beginTransaction();
sess.saveOrUpdate(toSave);
sess.flush();
tx.commit();
Full stack trace of any exception that occurs:
net.sf.hibernate.HibernateException: Batch update row count wrong: 0
at net.sf.hibernate.impl.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:65)
at net.sf.hibernate.impl.BatcherImpl.executeBatch(BatcherImpl.java:128)
at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2438)
at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2393)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2261)
at sample.ApplicationDao.genericSaveOrUpdate(ApplicationDao.java:656)
at sample.ApplicationDao.saveUpdateEntityDa(ApplicationDao.java:40)
at sample.test.ApplicationTest.testChangeFlagDelete(ApplicationTest.java:197)
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)
Name and version of the database you are using:
DB2 version 8.1
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt:
|