What's the difference between PESSIMISTIC_READ and PESSIMISTIC_WRITE in JPA?
问题 I have read the article Locking and Concurrency in Java Persistence 2.0, and run the sample application. But i still cant realize the difference between PESSIMISTIC_READ and PESSIMISTIC_WRITE. I tried to modify the code, and where the code using PESSIMISTIC_READ and PESSIMISTIC_WRITE will have the same result that the sql will invoked with "for update". 回答1: The difference lies in locking mechanism. PESSIMISTIC_READ lock means that dirty reads and non-repeatable reads are impossible when you