File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Row level lock in Hibernate

 
Jaikiran Pai
Marshal
Pie
Posts: 10444
227
IntelliJ IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there any way by which we can configure Row level locking of tables while using Hibernate. Currently, in our application, Hibernate generates table level lock queries. Our's is a J2EE application on Jboss-3.2.3 and Hibernate 2.1.3?

Thank you.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hibernate doesn't lock tables. All concurrent access issues are delegated to the RDBMS. How are you getting Hibernate to lock tables?
 
Jaikiran Pai
Marshal
Pie
Posts: 10444
227
IntelliJ IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have NOT mentioned explicitly any locking configurations in Hibernate. But whenever queries are fired through Hibernate i see logs similar to the one below:



[Edited code to improve formatting - Paul Sturrock]
[ December 14, 2005: Message edited by: Paul Sturrock ]
 
Jaikiran Pai
Marshal
Pie
Posts: 10444
227
IntelliJ IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there any way this can be avoided?
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmm. Can you post the code that generates this SQL? Also which Dialect are you using?
 
Jaikiran Pai
Marshal
Pie
Posts: 10444
227
IntelliJ IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We are using Teradata dialect :



As far as the code is concerned, we have created a hibernate object which is mapped to this SM_TABLE_RUN. Then we just invoke the get method on our persistence manager which invokes Hibernate session.get method.
This behavior is observed for all sort of database operations (insert,update,delete etc...) and not just select operation.

P.S.: Hibernate is being used as a MBean in our application
 
Jaikiran Pai
Marshal
Pie
Posts: 10444
227
IntelliJ IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Even a HQL like:


is issuing the following lock statements:

 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Teradata? That is not a supported database as far as I'm aware. You might want to speak to whoever wrote your Dialect, they will probably have more of a clue (since it wasn't the Hibernate developers). Also, doesn't Teradata use a serializable transaction isolation level by default?
[ December 14, 2005: Message edited by: Paul Sturrock ]
 
Jaikiran Pai
Marshal
Pie
Posts: 10444
227
IntelliJ IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Paul, Will try to get in touch with the guy who coded the dialect.
 
Jaikiran Pai
Marshal
Pie
Posts: 10444
227
IntelliJ IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Paul Sturrock:

Also, doesn't Teradata use a serializable transaction isolation level by default?

I have been informed that Teradata does NOT use a serializable transaction isolation level
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmm again. Are you explicitly applying a LockMode to the Session when you open it? I understood that it is posisble to add pessimistic locking to a row with this, but I've never heard of it locking a table.
 
Scott Johnson
Ranch Hand
Posts: 518
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Calling LOCKING TABLE XXX FOR ACCESS is telling Teradata that dirty or phantom reads (TRANSACTION_READ_UNCOMMITTED) are acceptable.

This is a good thing [for concurrency].

You are declaring that others can access and update the table while you are selecting from it.

The valid lock levels are Exclusive, Write, Read and Access.
[ December 14, 2005: Message edited by: Scott Johnson ]
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic