6
6
7
7
import jakarta .persistence .GenerationType ;
8
8
import jakarta .persistence .TemporalType ;
9
+ import jakarta .persistence .Timeout ;
9
10
import org .hibernate .Length ;
10
11
import org .hibernate .QueryTimeoutException ;
12
+ import org .hibernate .Timeouts ;
13
+ import org .hibernate .QueryTimeoutException ;
11
14
import org .hibernate .boot .model .FunctionContributions ;
12
15
import org .hibernate .boot .model .TypeContributions ;
13
16
import org .hibernate .dialect .aggregate .AggregateSupport ;
117
120
import org .jboss .logging .Logger ;
118
121
119
122
import 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 ;
123
123
import static org .hibernate .cfg .DialectSpecificSettings .ORACLE_USE_BINARY_FLOATS ;
124
124
import static org .hibernate .cfg .DialectSpecificSettings .ORACLE_OSON_DISABLED ;
125
125
import static org .hibernate .dialect .type .OracleJdbcHelper .getArrayJdbcTypeConstructor ;
@@ -1470,7 +1470,7 @@ public RowLockStrategy getWriteRowLockStrategy() {
1470
1470
}
1471
1471
1472
1472
@ Override
1473
- public String getForUpdateNowaitString () {
1473
+ public String getForUpdateNowaitString (){
1474
1474
return " for update nowait" ;
1475
1475
}
1476
1476
@@ -1494,12 +1494,36 @@ public String getForUpdateSkipLockedString(String aliases) {
1494
1494
return " for update of " + aliases + " skip locked" ;
1495
1495
}
1496
1496
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
+
1497
1521
private String withTimeout (String lockString , int timeout ) {
1498
1522
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 ;
1503
1527
};
1504
1528
}
1505
1529
0 commit comments