-->
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.  [ 5 posts ] 
Author Message
 Post subject: Version column when using Optimistic locking
PostPosted: Thu Feb 26, 2004 8:41 am 
Newbie

Joined: Thu Feb 26, 2004 6:42 am
Posts: 3
Location: Stockholm, Sweden
Hi folks,

I am faced with this problem:

I have a database on which I can do [b]no changes[/b]. With Middlegen I generate hbm.xml files and java files. On one table I like to use optimistic locking by version.

Is it possible to let Hibernate use an existing column as version column ?

My example table without optimistic locking: (A.hbm.xml)

[code]<hibernate-mapping>
<class name="data.hibernate.A" table="a">
<id name="Id" type="java.lang.String" column="ID">
<generator class="assigned" />
</id>
<property name="Ver" type="int" column="VER" not-null="true" length="11"/>
</class>
</hibernate-mapping>[/code]

I add this to make it work

[code]dynamic-update="true"
optimistic-lock="version"

<version column="`VER`" name="Ver"/>[/code]

When generating a java file from A.hbm.xml I get errors since there are two variables called "Ver"

Kindly submit any suggestion!

/capo


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 26, 2004 8:47 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Remove the <property name="ver">, you don't need it.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 26, 2004 9:16 am 
Newbie

Joined: Thu Feb 26, 2004 6:42 am
Posts: 3
Location: Stockholm, Sweden
Great!
It compiles but when I run my application I notice that the "Ver" column is never updated.

Have you any idea what I have missed ?

My environment is:
JDK 1.3.1_02
MySQL 4.0.13
JBoss 3.2.3
Hibernate 2.1.1


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 26, 2004 9:41 am 
Newbie

Joined: Thu Feb 26, 2004 6:42 am
Posts: 3
Location: Stockholm, Sweden
Igore my last question!

It do works!


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 26, 2004 9:41 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Weel you do not update the object.
Check the Hibernate logs

_________________
Emmanuel


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

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.