Win a copy of Spring Boot in Practice this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

Row level lock in Hibernate

 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is there any way this can be avoided?
 
Paul Sturrock
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hmm. Can you post the code that generates this SQL? Also which Dialect are you using?
 
Jaikiran Pai
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Even a HQL like:


is issuing the following lock statements:

 
Paul Sturrock
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Paul, Will try to get in touch with the guy who coded the dialect.
 
Jaikiran Pai
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 518
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic