HHH-16461 @Version + session.refresh(entity, LockMode.PESSIMISTIC_WRITE) leads to StaleObjectStateException
This commit is contained in:
parent
f78c5d375d
commit
55f46ced44
|
@ -70,4 +70,8 @@ public class SqmJdbcExecutionContextAdapter extends BaseExecutionContext {
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean upgradeLocks() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -97,4 +97,12 @@ public interface ExecutionContext {
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Does this query return objects that might be already cached
|
||||
* by the session, whose lock mode may need upgrading
|
||||
*/
|
||||
default boolean upgradeLocks(){
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -557,7 +557,7 @@ public abstract class AbstractEntityInitializer extends AbstractFetchParentAcces
|
|||
}
|
||||
|
||||
private void upgradeLockMode(RowProcessingState rowProcessingState) {
|
||||
if ( lockMode != LockMode.NONE ) {
|
||||
if ( lockMode != LockMode.NONE && rowProcessingState.upgradeLocks() ) {
|
||||
final EntityEntry entry =
|
||||
rowProcessingState.getSession().getPersistenceContextInternal()
|
||||
.getEntry( entityInstance );
|
||||
|
|
|
@ -196,4 +196,9 @@ public class RowProcessingStateStandardImpl extends BaseExecutionContext impleme
|
|||
public boolean hasCollectionInitializers() {
|
||||
return this.initializers.hasCollectionInitializers();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean upgradeLocks() {
|
||||
return executionContext.upgradeLocks();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue