Does PESSIMISTIC_WRITE lock the whole table?
Just to be sure that I correctly understand how things work. If I do em.lock(employee, LockModeType.PESSIMISTIC_WRITE); - will it block only this entity ( employee ) or the whole table Employees ? If it matters, I am talking about PostgreSQL . Anton Malyshev It should block only the entity. PostgreSQL hibernate dialect adds for update in case of write locks: https://github.com/hibernate/hibernate-orm/blob/master/hibernate-core/src/main/java/org/hibernate/dialect/PostgreSQL81Dialect.java#L549 (newer versions just use the same implementation) for update is treated row-wise by PostgreSQL: https:/