Skip to content

Commit 5e32cef

Browse files
committed
HHH-19336 - Proper implementation for JPA extended locking scope
HHH-19459 - LockScope, FollowOnLocking HHH-19501 - Session#lock w/ pessimistic locks for scopes HHH-19502 - Disallow SKIP_LOCKED with Session#lock
1 parent 9229e7f commit 5e32cef

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

hibernate-core/src/main/java/org/hibernate/dialect/lock/internal/SqlAstBasedLockingStrategy.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,14 @@ public void lock(
6161
int timeout,
6262
SharedSessionContractImplementor session) throws StaleObjectStateException, LockingStrategyException {
6363
if ( session instanceof EventSource eventSource ) {
64-
doLock( id, version, object, timeout, eventSource );
64+
doLock( id, version, timeout, eventSource );
6565
}
6666
else {
6767
throw new UnsupportedOperationException( "Optimistic locking strategies not supported in stateless session" );
6868
}
6969
}
7070

71-
private void doLock(Object id, Object version, Object object, int timeout, EventSource eventSource) {
71+
private void doLock(Object id, Object version, int timeout, EventSource eventSource) {
7272
final SessionFactoryImplementor factory = eventSource.getFactory();
7373

7474
final LockOptions lockOptions = new LockOptions( lockMode );

hibernate-core/src/main/java/org/hibernate/event/spi/LockEvent.java

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,24 +23,27 @@ public class LockEvent extends AbstractEvent {
2323
private final LockOptions lockOptions;
2424
private String entityName;
2525

26-
public LockEvent(String entityName, Object object, LockMode lockMode, EventSource source) {
27-
this( entityName, object, lockMode.toLockOptions(), source );
28-
}
29-
3026
public LockEvent(String entityName, Object object, LockOptions lockOptions, EventSource source) {
3127
super(source);
28+
3229
if (object == null) {
3330
throw new IllegalArgumentException( "Entity may not be null" );
3431
}
3532
if (lockOptions == null) {
3633
throw new IllegalArgumentException( "LockOptions may not be null" );
3734
}
38-
this.object = object;
39-
this.lockOptions = lockOptions;
4035
if ( lockOptions.getLockMode() == LockMode.UPGRADE_SKIPLOCKED
41-
|| lockOptions.getTimeout().milliseconds() == Timeouts.SKIP_LOCKED_MILLI ) {
36+
|| lockOptions.getTimeout().milliseconds() == Timeouts.SKIP_LOCKED_MILLI ) {
4237
throw new IllegalArgumentException( ILLEGAL_SKIP_LOCKED );
4338
}
39+
40+
this.entityName = entityName;
41+
this.object = object;
42+
this.lockOptions = lockOptions;
43+
}
44+
45+
public LockEvent(String entityName, Object object, LockMode lockMode, EventSource source) {
46+
this( entityName, object, lockMode.toLockOptions(), source );
4447
}
4548

4649
public LockEvent(Object object, LockMode lockMode, EventSource source) {

0 commit comments

Comments
 (0)