[ https://issues.apache.org/jira/browse/OPENJPA-2806?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17169844#comment-17169844 ]
chenlin commented on OPENJPA-2806: ---------------------------------- Entity Locking API: ’OpenJPA differentiates between PESSIMISTIC_READ and PESSIMISTIC_WRITE lock modes only with DB2 databases. While running with other databases, there is no distinction between these two modes because PESSIMISTIC_READ lock mode is upgraded to PESSIMISTIC_WRITE. In other words, only DB2 can achieve your expectations with PESSIMISTIC_READ. ‘ You are advised to use another method to implement the required functions. ps:https://openjpa.apache.org/builds/2.2.2/apache-openjpa/docs/jpa_overview_em_locking.html > PESSIMISTIC_READ takes out exclusive lock on Postgres > ----------------------------------------------------- > > Key: OPENJPA-2806 > URL: https://issues.apache.org/jira/browse/OPENJPA-2806 > Project: OpenJPA > Issue Type: Bug > Components: kernel > Affects Versions: 2.4.2, 3.0.0, 3.1.0 > Reporter: Pawel Veselov > Priority: Major > Attachments: openjpa-lock.zip > > > I've found out that using PESSIMISTIC_READ on an entity with postgres > uses 'for update' lock, which is actually exclusive. > I understand JPA specification says that it's permissible to do that, > but I really need a shared lock for what I'm trying to achieve. > Is it possible to control somehow? I've had to resolve to using native > queries, and I'd like to avoid this as much as possible... > Attached is a test. > Change App.java to control database properties for connection (top of > `main()`) > Run App.class to execute the test. If the lock taken by OpenJPA is exclusive, > then native query will fail (with an exception). > I'm testing on Postgres 9.6 > Tested with 2.4.2, 3.0.0 and 3.1.0 -- This message was sent by Atlassian Jira (v8.3.4#803005)