![]() With read/shared locks the database engine can guarantee that if a row is read, no other concurrent transaction can modify it thus preventing the non-repeatable read anomaly. If someone wants to write a row and acquires a write lock, only that single writer is allowed to access it and noone else, even reading is prohibited. ![]() Multiple readers can access the same row at the same time. There are two types of locks which can be differentiated, read locks for reading only the data and write locks for reading and writing the data. This is done by employing different kind of database locks. Pessimistic locking is all about the concept of avoiding the conflicts from happening. I’ll show you how to use it with Hibernate. Pessimistic locking is also a key tool to deal with conflicts. Implicit optimistic locking has been already covered, if you didn’t have the chance to read my article on it, make sure you do it before continuing. There are two ways to deal with concurrency conflicts, optimistic locking and pessimistic locking. ![]() Pessimistic locking in JPA and Hibernate.Optimistic locking in JPA and Hibernate.SERIES Concurrency control with JPA/Hibernate
0 Comments
Leave a Reply. |