Hibernate version: hibernate-2.1.7c
Mapping documents:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping package="com.agentscape.associate.to">
<class name="PersonTO" table="people">
<id name="id" column="id" type="long" unsaved-value="0" >
<generator class="identity"/>
</id>
<version name="version" type="long"/>
<property name="firstName"/>
<property name="lastName"/>
<many-to-one name="address" column="addressId" cascade="all" outer-join="true" />
<many-to-one name="contactInformation" column="contactInformationId" cascade="all"/>
<map name="roles" inverse="true" cascade="all" >
<key column="personId" />
<index column="type" type="string"/>
<one-to-many class="RoleTO"/>
</map>
<joined-subclass name="ContactTO" table="contacts">
<key column="personId"/>
<many-to-one name="parent" column="agentRoleId" class="AgentRoleTO"/>
</joined-subclass>
</class>
Name and version of the database you are using: MySQL 4.0.20d
I take these steps:
1 - Load ContactTO 'contact' variable with Hibernate.
2 - Serialize
3 - Unserialize
4 - update contact
5 - print out contact.getVersion()
6 - call session.saveOrUpdateCopy(contact);
7 - print out contact.getVersion() again
I see the same version output for steps 5 and 7, even though the version has been updated in the database.
Next, I tried this:
1 - Load ContactTO 'contact' variable with Hibernate.
2 - update contact
3 - print out contact.getVersion()
4 - call session.update(contact);
5 - print out contact.getVersion() again
Like this, I see the the version on my object being updated.
Should saveOrUpdateCopy be updated the version on my object too?
I can create an example and post if needed.
Thanks in advance.