Bug 396266 - JTA transaction marked for rollback when failing to acquire lock with 'SELECT FOR UPDATE NOWAIT'
Summary: JTA transaction marked for rollback when failing to acquire lock with 'SELECT...
Status: NEW
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: PC Linux
: P2 normal (vote)
Target Milestone: ---   Edit
Assignee: Nobody - feel free to take it CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-12-11 07:08 EST by Waf Waf CLA
Modified: 2022-06-09 10:31 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Waf Waf CLA 2012-12-11 07:08:30 EST
When trying to 'SELECT FOR UPDATE NOWAIT' using JPA on an Oracle DB, if the lock wasn't acquired then a PessimisticLockException is thrown instead of a LockTimeoutException, which is the expected exception (thrown in any other case where the timeout is larger than 0).

This causes the JTA transaction to be marked for rollback (as written in the PessimisticLockException's documentation), but it really shouldn't do that.

Code example:
props.put("javax.persistence.lock.timeout", 0);
em.find(MyEntity.class, id, LockModeType.PESSIMISTIC_READ, props);

It also happens when running a native query.

The following code will produce the expected behavior, but it requires invoking EclipseLink's specific classes:
em.unwrap(Session.class).executeQuery(((JpaQuery)query).getDatabaseQuery())

btw, I'm not 100% sure about my EclipseLink version. I'm using the default EclipseLink which comes with Weblogic 12.1, and in the logs it says it's version 2.3.2.
Comment 1 Tom Ware CLA 2013-02-12 08:57:33 EST
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 2 Eclipse Webmaster CLA 2022-06-09 10:31:00 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink