Announcement Announcement Module
Collapse
No announcement yet.
jpa & hibernate lock() Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • jpa & hibernate lock()

    Hi, i'd like to know if the pessimistic locking in hibernate works the same as with the entity manager in jpa.

    F.Example

    in hibernate
    Session.lock()
    in jpa
    entityManager.lock()

    I've been reading in diferent books ffrom where i undesratand
    that the hibernate lock() (F.E. WRITELOCK) prevents concurrent threads to access the locked object till the transaction finishes.(I think this works like a kind of mutex)
    But in jpa, the lock(), just increments the version number.

    I'm interested in undestanding this because i need a kind of mutext behaivour, to prevent concurrent thread to read and update an object, which i used to give unique ids.

    Thanks for your help!
Working...
X