-->
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.  [ 7 posts ] 
Author Message
 Post subject: Optimistic Locking....
PostPosted: Mon Feb 06, 2006 6:07 am 
Beginner
Beginner

Joined: Mon Jan 09, 2006 8:02 am
Posts: 22
Hi,
I am planning to use Database Level Managed Versioning to implement Optimistic Locking. ie: Will control version at the Database Level via Triggers. Now i need to genrate an Update Command which would look like

Update table
set col1 = x, col2 = y
where Primary_key = value
and version = value

Any Ideas how can i generate such a Update Command....


Regards

Prasanth


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 06, 2006 7:38 am 
Expert
Expert

Joined: Thu Jan 19, 2006 4:29 pm
Posts: 348
NHibernate has built-in optimistic locking, see the <version> element. I belive that it should also work if new version value is assigned by trigger... Only that, if trigger assigns a number different than NHibernate thinks should be, You must refresh object after save. Maybe NHibernate can be configured to do it automatically, I do not know.. (I'm just a newbie :-P )


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 06, 2006 8:14 am 
Beginner
Beginner

Joined: Mon Jan 09, 2006 8:02 am
Posts: 22
Hey Thankz,
For some funny Reason <version> tag dosnt work if it is placed after a <property> tag. But works well when placed after the <id> Tag.


Also What i wanted was that the versin should not Update the version column. IS that Possible. If not is there any other way in which similar Could be achieved. As i might be using the Oracle inbuilt ORA_SCN Number to Maintain Versioning.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 06, 2006 4:16 pm 
Beginner
Beginner

Joined: Mon Nov 21, 2005 6:38 pm
Posts: 30
Location: New Zealand
Quote:
For some funny Reason <version> tag dosnt work if it is placed after a <property> tag. But works well when placed after the <id> Tag.


The NHibernate mapping schema demands that the tags in a mapping file follow a specified sequence, which is why <version> cannot follow a <property> tag.

Quote:
Also What i wanted was that the versin should not Update the version column.


Are you saying that you want to use NHibernate's versioning but don't want NHibernate to modify any version numbers? If so, then I can't see much point in using NHibernate's versioning at all. Can you provide some information as to why you want to do this?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 07, 2006 1:14 am 
Beginner
Beginner

Joined: Mon Jan 09, 2006 8:02 am
Posts: 22
What I am Looking for is updating the version Col Using Triggers. I am not planning to Update versions in The Business Logic. Thats why i want the Version not to update the version Col.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 13, 2006 4:44 am 
Beginner
Beginner

Joined: Tue Jan 17, 2006 12:55 pm
Posts: 49
NHibernate manages the versioning for you behind the scenes.. you do not need the triggers


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 14, 2006 5:54 am 
Expert
Expert

Joined: Tue Aug 23, 2005 5:52 am
Posts: 335
...which is fine as long as your NHibernate application is the only thing updating your database. Sometimes it's nice to have versioning controlled at the lowest possible level.

Symon.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 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.