-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: saveOrUpdateCopy not updating version on object?
PostPosted: Wed Jan 12, 2005 10:31 am 
Beginner
Beginner

Joined: Thu Oct 23, 2003 1:17 pm
Posts: 44
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.