-->
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.  [ 4 posts ] 
Author Message
 Post subject: Locking an entire table
PostPosted: Sun Sep 25, 2005 7:30 pm 
Is it possible in NHibernate to lock an entire table against read and writres. Basically I have a bidirectional 1-M relationship in which I need to query a table if the 1 side of the relationships exists and use it if it does. Otherwise, I want to create a new row in the table a use it subsequently.

thanks,
craig


Top
  
 
 Post subject:
PostPosted: Mon Sep 26, 2005 4:01 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
No, it's not possible but you can obtain Connection from a session and use that to issue any commands you need.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 26, 2005 8:50 am 
Regular
Regular

Joined: Tue May 31, 2005 9:55 am
Posts: 67
Thanks Sergey,

Is there something specific in NHibernate that might help me achieve this in a different way?

thanks,
craig


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 26, 2005 6:35 pm 
Contributor
Contributor

Joined: Sun Jun 26, 2005 5:03 am
Posts: 51
Location: London, UK
If you set the connection isolation mode to Serializable, then most databases will acquire a read lock over the range of the values that you are querying over. That way, if you query again, you receive exactly the same set of values.

So, if the data is not there, no-one else will be permitted to commit a transaction that puts it there whilst your transaction is active.

Note that although Serializable is strictly correct, you can end up locking a large portion of the database out from other people so make sure that the transaction is as tight as possible.

_________________
Paul Hatcher
NHibernate Team


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