Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 341478 - setLockMode(LockModeType.PESSIMISTIC_READ) on an EntityManager does not result in a select for update
Summary: setLockMode(LockModeType.PESSIMISTIC_READ) on an EntityManager does not resul...
Status: NEW
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: PC other
: P2 normal with 1 vote (vote)
Target Milestone: ---   Edit
Assignee: Nobody - feel free to take it CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-03-31 09:10 EDT by Missing name Mising name CLA
Modified: 2022-06-09 10:21 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Missing name Mising name CLA 2011-03-31 09:10:41 EDT
Build Identifier: 2.0.1.v20100213-r6600

The following code does a join on 2 tables and tries to get an entity object returned that is locked. It does not result in a locked row on the account table but I think it should.

public static Account getLockedAccount(EntityManager em, String id, String type) {
        Query q = em.createNativeQuery("select A.* from account A, account_mapping M where M.identifier=? and M.identifier_type=? and M.account_id=A.account_id", Account.class);
        q.setParameter(1, id);
        q.setParameter(2, type);
        q.setLockMode(LockModeType.PESSIMISTIC_READ);
        Account acc = (Account) q.getSingleResult();
        return acc;
    }

Reproducible: Always

Steps to Reproduce:
1. Run similar code as provided
2.
3.
Comment 1 Tom Ware CLA 2011-04-06 09:24:36 EDT
It is a good idea to go through one of the various support mechanisms before filing a bug.  (users mailing list or the newsgroup)  The audience is fairly wide and the chance of you getting feedback about what is going wrong, whether it is a bug and a workaround is very good.  The feedback for items entered in the bug database will be slower.
Comment 2 Missing name Mising name CLA 2011-04-06 09:55:02 EDT
Thanks, I found a workaround by not doing a join and its fine. I logged the bug merely as a means for future improvement of the stack.
Comment 3 Tom Ware CLA 2011-04-28 10:00:58 EDT
Setting target and priority.  See the following page for the meanings of these fields:

http://wiki.eclipse.org/EclipseLink/Development/Bugs/Guidelines

Community: Please vote for this bug if it is important to you.  Votes are one of the main criteria we use to determine which bugs to fix next.
Comment 4 Eclipse Webmaster CLA 2022-06-09 10:21:22 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink