66
77import jakarta .persistence .GenerationType ;
88import jakarta .persistence .TemporalType ;
9+ import jakarta .persistence .Timeout ;
910import org .hibernate .Length ;
1011import org .hibernate .QueryTimeoutException ;
12+ import org .hibernate .Timeouts ;
13+ import org .hibernate .QueryTimeoutException ;
1114import org .hibernate .boot .model .FunctionContributions ;
1215import org .hibernate .boot .model .TypeContributions ;
1316import org .hibernate .dialect .aggregate .AggregateSupport ;
116119import org .jboss .logging .Logger ;
117120
118121import static java .util .regex .Pattern .CASE_INSENSITIVE ;
119- import static org .hibernate .LockOptions .NO_WAIT ;
120- import static org .hibernate .LockOptions .SKIP_LOCKED ;
121- import static org .hibernate .LockOptions .WAIT_FOREVER ;
122122import static org .hibernate .cfg .DialectSpecificSettings .ORACLE_USE_BINARY_FLOATS ;
123123import static org .hibernate .cfg .DialectSpecificSettings .ORACLE_OSON_DISABLED ;
124124import static org .hibernate .dialect .type .OracleJdbcHelper .getArrayJdbcTypeConstructor ;
@@ -1464,7 +1464,7 @@ public RowLockStrategy getWriteRowLockStrategy() {
14641464 }
14651465
14661466 @ Override
1467- public String getForUpdateNowaitString () {
1467+ public String getForUpdateNowaitString (){
14681468 return " for update nowait" ;
14691469 }
14701470
@@ -1488,12 +1488,36 @@ public String getForUpdateSkipLockedString(String aliases) {
14881488 return " for update of " + aliases + " skip locked" ;
14891489 }
14901490
1491+ private String withTimeout (String lockString , Timeout timeout ) {
1492+ return withTimeout ( lockString , timeout .milliseconds () );
1493+ }
1494+
1495+ @ Override
1496+ public String getWriteLockString (Timeout timeout ) {
1497+ return withTimeout ( getForUpdateString (), timeout );
1498+ }
1499+
1500+ @ Override
1501+ public String getWriteLockString (String aliases , Timeout timeout ) {
1502+ return withTimeout ( getForUpdateString (aliases ), timeout );
1503+ }
1504+
1505+ @ Override
1506+ public String getReadLockString (Timeout timeout ) {
1507+ return getWriteLockString ( timeout );
1508+ }
1509+
1510+ @ Override
1511+ public String getReadLockString (String aliases , Timeout timeout ) {
1512+ return getWriteLockString ( aliases , timeout );
1513+ }
1514+
14911515 private String withTimeout (String lockString , int timeout ) {
14921516 return switch (timeout ) {
1493- case NO_WAIT -> supportsNoWait () ? lockString + " nowait" : lockString ;
1494- case SKIP_LOCKED -> supportsSkipLocked () ? lockString + " skip locked" : lockString ;
1495- case WAIT_FOREVER -> lockString ;
1496- default -> supportsWait () ? lockString + " wait " + getTimeoutInSeconds ( timeout ) : lockString ;
1517+ case Timeouts . NO_WAIT_MILLI -> supportsNoWait () ? lockString + " nowait" : lockString ;
1518+ case Timeouts . SKIP_LOCKED_MILLI -> supportsSkipLocked () ? lockString + " skip locked" : lockString ;
1519+ case Timeouts . WAIT_FOREVER_MILLI -> lockString ;
1520+ default -> supportsWait () ? lockString + " wait " + Timeouts . getTimeoutInSeconds ( timeout ) : lockString ;
14971521 };
14981522 }
14991523
0 commit comments