-->
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: Does database generated <version> work?
PostPosted: Mon Aug 06, 2007 11:35 am 
Newbie

Joined: Sat Aug 04, 2007 10:46 am
Posts: 8
Nhibernate 1.2

Hi,
Sorry for the slight dupe of a previously ignored post, but this strikes me as either a serious problem, or an oversight in the documentation.

I am trying to use <version> in a persistent class to allow for optimistic-locking, collision detection. In my mapping I quite plainly have:

<version column="version" name="version" type="TIMESTAMP" access="field" generated="ALWAYS">

Now, when autogenerating the schema, NHiberate creates a "datetime" SQL type in MySQL. It then DOES NOT auto generate the value. When I change the SQL type in the database to "timestamp" it works correctly on insert.

I tried the other verion types (int, long, etc.) with generated="ALWAYS" and Hibernate sets the value to 0 and never updates it automatically. Including when I leave the generated schema type as "datetime", it is all 0's.

I saw a lengthy discussion about this from 2004 (however I am not using Java), but alas, I expect generated="ALWAYS" to mean the database generates the value, and it does not.

I also expect type "timestamp" to be the equivalent of database column type "timestamp". Since it is the only condition where it actually works, but hibernate does not map to this obvious type.

thanks,
S
[/url]


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.