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.  [ 8 posts ] 
Author Message
 Post subject: <version> element and sql server timestamp column
PostPosted: Thu Aug 30, 2007 9:23 am 
Beginner
Beginner

Joined: Wed Aug 29, 2007 8:23 am
Posts: 31
hello guys.

i've finally starting using nhibernate in a professional project and i must say that i'm enjoying it a lot. However, there's a little problem with theway that the <version> element works.

According to the docs: "Version numbers may be of type Int64, Int32, Int16, Ticks, Timestamp, or TimeSpan (or their nullable counterparts in .NET 2.0). "

in my case, i'm using sql server and the version column is set to timestamp (SQL) which maps to a byte[] in C#. Now, in this case i might be able to change the type of column (for instance, to an int). However, what i'd really like to do is configure my <version> element so that it uses my sql server timestamp column for concurrency control. is this possible? any advices on how to achieve this?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 31, 2007 8:51 am 
Expert
Expert

Joined: Fri May 13, 2005 11:13 am
Posts: 292
Location: Rochester, NY
Using a DB generated value for concurrency control through <version> is not supported. There may be ways to use it for 'manual' concurrency control--see the more recent messages on this thread.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 31, 2007 1:53 pm 
Beginner
Beginner

Joined: Wed Aug 29, 2007 8:23 am
Posts: 31
hum...damn. this sucks. most of the existing databases with which i have to work use a timestamp column for concurrency control.

so, are there any workarounds for this? or are you just using ints for concurrency?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 04, 2007 11:48 am 
Expert
Expert

Joined: Fri May 13, 2005 11:13 am
Posts: 292
Location: Rochester, NY
I just use ints, which unfortunately means that I need to do manual increments from the DB side.

As for a workaround: did you check out the link I provided above (http://forum.hibernate.org/viewtopic.php?t=962174)? It's not a complete solution, but it is a start...


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 04, 2007 12:47 pm 
Beginner
Beginner

Joined: Wed Aug 29, 2007 8:23 am
Posts: 31
hello.

hum...i was under the assumption that nhibernate will automatically update the integer, though i can be wrong. am i wrong?

thanks again.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 04, 2007 4:41 pm 
Expert
Expert

Joined: Fri May 13, 2005 11:13 am
Posts: 292
Location: Rochester, NY
You are right, sorry, I was confusing. What I meant is that when I make updates directly via SQL and stored procedures, I have to include version updates manually.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 04, 2007 4:42 pm 
Beginner
Beginner

Joined: Wed Aug 29, 2007 8:23 am
Posts: 31
hello again.
oh, ok. got it:)

thanks for your help.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 17, 2007 11:06 pm 
Newbie

Joined: Mon Sep 17, 2007 10:30 pm
Posts: 3
Location: VIET NAM
The idea was already published on CodeProject. Here is a link:
http://www.codeproject.com/useritems/Op ... xTable.asp
Hopefully you can found the useful suggestion.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 8 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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.