I have a test application where one thread selects a row from the database, and goes to sleep.
Another thread wakes up and selects the same row, modifies the content and commits the changes.
When the first thread wakes up, tries to modify the same row and commit it, i expect a StaleObjectStateException to be thrown, but instead I am getting HibernateException(row not found)
Note that the same application works fine and StaleStateException is thrown in hibernate version 3.1, but in case of 2.1.8 it does not seem to work.
My mapping file is as below:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping
PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class name="com.fst.example.Event" table="EVENT_CMPTEST" dynamic-update="true">
<cache usage="read-write"/>
<id name="id" type="string" column="ID">
<generator class = "uuid.hex" />
</id>
<version name="version" column="VERSION"/>
<property name="eventType" type="string" column="EVENT_TYPE"/>
<property name="timeReceived" type="timestamp" column="RECEIVED_AT" update="false"/>
<property name="expiryTime" type="timestamp" column="EXPIRES_AT" update="false"/>
<property name="deliveryTime" type="timestamp" column="DELIVER_AT" update="false"/>
<property name="host" type="string" column="HOST_NAME"/>
</class>
</hibernate-mapping>
I have an attribute version, and the setter and the getter for the same in the bean.
Hibernate version: 2.1.8
Stack Trace:
net.sf.hibernate.HibernateException: SQL insert, update or delete failed (row not found)
at net.sf.hibernate.impl.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:25)
at net.sf.hibernate.persister.EntityPersister.update(EntityPersister.java:661)
at net.sf.hibernate.persister.EntityPersister.update(EntityPersister.java:621)
at net.sf.hibernate.impl.ScheduledUpdate.execute(ScheduledUpdate.java:52)
at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2449)
at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2435)
at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2393)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2261)
at net.sf.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:61)
at com.fst.example.TestExample.main(TestExample.java:67)
12:28:15,941 ERROR SessionImpl:2400 - Could not synchronize database state with session
Name and version of the database you are using: MySQL , version 5
Please let me know if I have missed out on anything, or if it is a bug in 2 version. I am having problems in migrating to version 3 as there are a lot of dependencies in my application. It would be the best if I can get it working in the version 2.1.8.
|