-->
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.  [ 3 posts ] 
Author Message
 Post subject: How to Lock one table when Insertion is going on?
PostPosted: Tue May 15, 2007 9:54 am 
Newbie

Joined: Mon Apr 23, 2007 9:22 am
Posts: 6
Hi,

I am using Hibernate3.2 and SQL Server 2000 as database. I want to do one thing in my application that when one user is inserting data, other user can not update,delete or insert data in same table. How i can implement that. Is session.lock() method will works or there is other way to do same.

Please help me.
Thanks.


Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:

Mapping documents:

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Name and version of the database you are using:

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


Problems with Session and transaction handling?

Read this: http://hibernate.org/42.html


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 16, 2007 12:20 am 
Senior
Senior

Joined: Sat Aug 19, 2006 6:31 pm
Posts: 139
Session.lock should work.

Although it sounds like what you really want is "SERIALIZABLE" reads isolation level. So you might want to try setting the hibernate.connection.isolation property in hibernate.cfg.xml as well.

_________________
Don't forget to rate the reply if it helps..:)

Budyanto


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 16, 2007 12:34 am 
Regular
Regular

Joined: Mon Mar 26, 2007 12:38 am
Posts: 119
Hi,
>>> when one user is inserting data, other user can not update,delete or insert data in same table
Hibernate supports row level locks.
session.lock() does not support obtaining table locks.
We might have to rely on native sql and underlying database.

session.createSQLQuery(" LOCK table myTable in exclusive mode nowait").executeUpdate() ;

------------------------------------------
Rate the reply if you find it helpful


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