Hi!
I am having a strange problem when adding a version to a domain object operated by Hibernate.
In other objects (where this is successful), the only modification which is done is editing the mapping document, but with this particular object this does not work. I am expecting that hibernate throws an exception if the version of the updated object does not comply, but this is not done...
Hibernate is updating (incrementing) the version property in the database, but this is obvious not used when updating the object.
As I mentioned I have objects which is using this feature successfully, but whit this object, this want comply. The only difference that I can think of in the environment is that this object is being updated in an EJB which has transactions enabled, where the other EJBs which is doing this correctly has transactions disabled. I would not think that this should affect the behavior of hibernate. For the cause of testing this we disabled the transactions but there was no change.
Is there anything besides the mapping document that needs to be configured to enable optimistic locking when updating of objects? Does anyone have an idea of what could be causing this problem? Please help!
Hibernate version:
Hibernate3 3.0.5
Mapping documents:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
<hibernate-mapping>
<!--
Created by the Middlegen Hibernate plugin 2.1
http://boss.bekk.no/boss/middlegen/
http://www.hibernate.org/
-->
<class
name="some.Object"
table="T_OBJECT"
>
<meta attribute="implement-equals" inherit="false">true</meta>
<!--
Merged T_OBJECT.merge into T_OBJECT.hbm.xml
-->
<!-- No ${plugin.mergedir}/T_OBJECT.merge found.
hibernate
-->
<id
name="id"
type="java.lang.Integer"
column="ID"
unsaved-value="0"
>
<generator class="identity" />
</id>
<version
name="versjon"
type="java.lang.Integer"
column="VERSJON"
unsaved-value="null"
/>
...
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():Handled by spring-framework v 1.2.8
Full stack trace of any exception that occurs:n/a
Name and version of the database you are using:db2 8x
The generated SQL:Code:
update T_OBJECT set VERSJON=?, ... where ID=? and VERSJON=?"
Debug level Hibernate log excerpt:
?