mirror of
https://github.com/hibernate/hibernate-orm
synced 2025-02-17 00:24:57 +00:00
HHH-16461 @Version + session.refresh(entity, LockMode.PESSIMISTIC_WRITE) leads to StaleObjectStateException
This commit is contained in:
parent
f80b90735e
commit
c5893e7919
@ -75,4 +75,8 @@ public boolean hasQueryExecutionToBeAddedToStatistics() {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean upgradeLocks() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -90,4 +90,12 @@ default boolean hasQueryExecutionToBeAddedToStatistics() {
|
|||||||
return false;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -571,7 +571,7 @@ && getEntityKey().getIdentifier().equals( executionContext.getEntityId() ) ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void upgradeLockMode(RowProcessingState rowProcessingState) {
|
private void upgradeLockMode(RowProcessingState rowProcessingState) {
|
||||||
if ( lockMode != LockMode.NONE ) {
|
if ( lockMode != LockMode.NONE && rowProcessingState.upgradeLocks() ) {
|
||||||
final EntityEntry entry =
|
final EntityEntry entry =
|
||||||
rowProcessingState.getSession().getPersistenceContextInternal()
|
rowProcessingState.getSession().getPersistenceContextInternal()
|
||||||
.getEntry( entityInstance );
|
.getEntry( entityInstance );
|
||||||
|
@ -201,4 +201,9 @@ public Initializer resolveInitializer(NavigablePath path) {
|
|||||||
public boolean hasCollectionInitializers() {
|
public boolean hasCollectionInitializers() {
|
||||||
return this.initializers.hasCollectionInitializers();
|
return this.initializers.hasCollectionInitializers();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean upgradeLocks() {
|
||||||
|
return executionContext.upgradeLocks();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user