javax.persistence.lock.timeout Is Set As Seconds Instead of Milliseconds (Doc ID 2101956.1)

Last updated on JUNE 09, 2016

Applies to:

Oracle WebLogic Server - Version 12.1.3.0.0 and later
Information in this document applies to any platform.

Symptoms

javax.persistence.lock.timeout is defined as "milliseconds" in the JPA specification. But actually, it is set as "seconds" in SQL for Oracle Database.

 

When javax.persistence.lock.timeout is 10000 (milliseconds), the following SQL is expected.

SELECT KEY1, COL1 FROM LOCKTEST WHERE (KEY1 = ?) FOR UPDATE WAIT 10

but, "10000" is set instead of "10".



Per JSR-000338 Java Persistence 2.1 Specification for Evaluation :

3.4.4.3 Lock Mode Properties and Uses
The following property is defined by this specification for use in pessimistic locking, as described in section 3.4.3:
javax.persistence.lock.scope
This property may be used with the methods of the EntityManager interface
that allow lock modes to be specified, the Query and TypedQuery setLockMode methods, and the
NamedQuery annotation.
When specified, this property must be observed. The provider is permitted to
lock more (but not fewer) rows than requested.
The following hint is defined by this specification for use in pessimistic locking.

javax.persistence.lock.timeout // time in milliseconds

  

 Per The Java EE 6 Tutorial - Pessimistic Locking Timeouts :

The length of time in milliseconds the persistence provider should wait to obtain a lock on the database tables may be specified using the javax.persistence.lock.timeout property.

 


Per EclipseLink/Development/JPA 2.0/standard properties : 

javax.persistence.lock.timeout - value in milliseconds for pessimistic lock timeout

 

 

However,  "seconds" is used on WAIT section of select in Oracle Database.
Per Database SQL Language Reference :


NOWAIT | WAIT

The NOWAIT and WAIT clauses let you tell the database how to proceed if the
SELECT statement attempts to lock a row that is locked by another user.

Specify NOWAIT to return control to you immediately if a lock exists.

Specify WAIT to instruct the database to wait integer seconds for the row to
become available and then return control to you.

  

 

Cause

Sign In with your My Oracle Support account

Don't have a My Oracle Support account? Click to get started

My Oracle Support provides customers with access to over a
Million Knowledge Articles and hundreds of Community platforms