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 ;
117120import org .jboss .logging .Logger ;
118121
119122import static java .util .regex .Pattern .CASE_INSENSITIVE ;
120- import static org .hibernate .LockOptions .NO_WAIT ;
121- import static org .hibernate .LockOptions .SKIP_LOCKED ;
122- import static org .hibernate .LockOptions .WAIT_FOREVER ;
123123import static org .hibernate .cfg .DialectSpecificSettings .ORACLE_USE_BINARY_FLOATS ;
124124import static org .hibernate .cfg .DialectSpecificSettings .ORACLE_OSON_DISABLED ;
125125import static org .hibernate .dialect .type .OracleJdbcHelper .getArrayJdbcTypeConstructor ;
@@ -1470,7 +1470,7 @@ public RowLockStrategy getWriteRowLockStrategy() {
14701470 }
14711471
14721472 @ Override
1473- public String getForUpdateNowaitString () {
1473+ public String getForUpdateNowaitString (){
14741474 return " for update nowait" ;
14751475 }
14761476
@@ -1494,12 +1494,36 @@ public String getForUpdateSkipLockedString(String aliases) {
14941494 return " for update of " + aliases + " skip locked" ;
14951495 }
14961496
1497+ private String withTimeout (String lockString , Timeout timeout ) {
1498+ return withTimeout ( lockString , timeout .milliseconds () );
1499+ }
1500+
1501+ @ Override
1502+ public String getWriteLockString (Timeout timeout ) {
1503+ return withTimeout ( getForUpdateString (), timeout );
1504+ }
1505+
1506+ @ Override
1507+ public String getWriteLockString (String aliases , Timeout timeout ) {
1508+ return withTimeout ( getForUpdateString (aliases ), timeout );
1509+ }
1510+
1511+ @ Override
1512+ public String getReadLockString (Timeout timeout ) {
1513+ return getWriteLockString ( timeout );
1514+ }
1515+
1516+ @ Override
1517+ public String getReadLockString (String aliases , Timeout timeout ) {
1518+ return getWriteLockString ( aliases , timeout );
1519+ }
1520+
14971521 private String withTimeout (String lockString , int timeout ) {
14981522 return switch (timeout ) {
1499- case NO_WAIT -> supportsNoWait () ? lockString + " nowait" : lockString ;
1500- case SKIP_LOCKED -> supportsSkipLocked () ? lockString + " skip locked" : lockString ;
1501- case WAIT_FOREVER -> lockString ;
1502- default -> supportsWait () ? lockString + " wait " + getTimeoutInSeconds ( timeout ) : lockString ;
1523+ case Timeouts . NO_WAIT_MILLI -> supportsNoWait () ? lockString + " nowait" : lockString ;
1524+ case Timeouts . SKIP_LOCKED_MILLI -> supportsSkipLocked () ? lockString + " skip locked" : lockString ;
1525+ case Timeouts . WAIT_FOREVER_MILLI -> lockString ;
1526+ default -> supportsWait () ? lockString + " wait " + Timeouts . getTimeoutInSeconds ( timeout ) : lockString ;
15031527 };
15041528 }
15051529
0 commit comments