My Oracle Support Banner

javax.persistence.lock.timeout に指定された値が"ミリ秒"ではなく"秒"単位でSQL文に設定される (Doc ID 2101964.1)

Last updated on OCTOBER 29, 2020

適用範囲:

Oracle WebLogic Server - バージョン 12.1.3.0.0 以降
この文書の内容はすべてのプラットフォームに適用されます。

現象

javax.persistence.lock.timeout に指定された値が"ミリ秒"ではなく"秒"単位で Oracle データベースに対するSQL文に設定される。
JPAの仕様では"ミリ秒"で設定することが記述されています。

 

例:

javax.persistence.lock.timeout に 10000 (ミリ秒)が設定された場合, 以下の様になることが期待されますが、

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

実際には"10" の代わりに "10000" が設定されます。

 

以下はJPAの仕様とOracle DBのドキュメントからの該当部分の抜粋です 

 

JSR-000338 Java Persistence 2.1 Specification for Evaluation

http://download.oracle.com/otndocs/jcp/persistence-2_1-fr-eval-spec/index.html


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

 


https://docs.oracle.com/javaee/6/tutorial/doc/gkjiu.html


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.


https://wiki.eclipse.org/EclipseLink/Development/JPA_2.0/standard_properties

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

 

"seconds" is used on WAIT section of select in Oracle Database.

https://docs.oracle.com/cd/B28359_01/server.111/b28286/statements_10002.htm


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.

原因

To view full details, 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 a vibrant support community of peers and Oracle experts.