mirror of
https://github.com/hibernate/hibernate-orm
synced 2025-02-07 11:48:18 +00:00
remove deprecated operations of LockOptions
This commit is contained in:
parent
9823fccfe8
commit
2a03f97b73
@ -18,6 +18,7 @@
|
|||||||
import org.hibernate.query.Query;
|
import org.hibernate.query.Query;
|
||||||
import org.hibernate.query.spi.QueryOptions;
|
import org.hibernate.query.spi.QueryOptions;
|
||||||
|
|
||||||
|
import static jakarta.persistence.PessimisticLockScope.NORMAL;
|
||||||
import static java.util.Collections.emptySet;
|
import static java.util.Collections.emptySet;
|
||||||
import static java.util.Collections.unmodifiableSet;
|
import static java.util.Collections.unmodifiableSet;
|
||||||
|
|
||||||
@ -138,7 +139,7 @@ public class LockOptions implements FindOption, RefreshOption, Serializable {
|
|||||||
private final boolean immutable;
|
private final boolean immutable;
|
||||||
private LockMode lockMode;
|
private LockMode lockMode;
|
||||||
private int timeout;
|
private int timeout;
|
||||||
private boolean extendedScope;
|
private PessimisticLockScope pessimisticLockScope;
|
||||||
private Boolean followOnLocking;
|
private Boolean followOnLocking;
|
||||||
private Map<String, LockMode> aliasSpecificLockModes;
|
private Map<String, LockMode> aliasSpecificLockModes;
|
||||||
|
|
||||||
@ -150,6 +151,7 @@ public LockOptions() {
|
|||||||
immutable = false;
|
immutable = false;
|
||||||
lockMode = LockMode.NONE;
|
lockMode = LockMode.NONE;
|
||||||
timeout = WAIT_FOREVER;
|
timeout = WAIT_FOREVER;
|
||||||
|
pessimisticLockScope = NORMAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -162,6 +164,7 @@ public LockOptions(LockMode lockMode) {
|
|||||||
immutable = false;
|
immutable = false;
|
||||||
this.lockMode = lockMode;
|
this.lockMode = lockMode;
|
||||||
timeout = WAIT_FOREVER;
|
timeout = WAIT_FOREVER;
|
||||||
|
pessimisticLockScope = NORMAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -175,6 +178,7 @@ public LockOptions(LockMode lockMode, int timeout) {
|
|||||||
immutable = false;
|
immutable = false;
|
||||||
this.lockMode = lockMode;
|
this.lockMode = lockMode;
|
||||||
this.timeout = timeout;
|
this.timeout = timeout;
|
||||||
|
pessimisticLockScope = NORMAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -189,7 +193,7 @@ public LockOptions(LockMode lockMode, int timeout, PessimisticLockScope scope) {
|
|||||||
immutable = false;
|
immutable = false;
|
||||||
this.lockMode = lockMode;
|
this.lockMode = lockMode;
|
||||||
this.timeout = timeout;
|
this.timeout = timeout;
|
||||||
this.extendedScope = scope == PessimisticLockScope.EXTENDED;
|
this.pessimisticLockScope = scope;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -199,6 +203,7 @@ private LockOptions(boolean immutable, LockMode lockMode) {
|
|||||||
this.immutable = immutable;
|
this.immutable = immutable;
|
||||||
this.lockMode = lockMode;
|
this.lockMode = lockMode;
|
||||||
timeout = WAIT_FOREVER;
|
timeout = WAIT_FOREVER;
|
||||||
|
pessimisticLockScope = NORMAL;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Determine of the lock options are empty.
|
* Determine of the lock options are empty.
|
||||||
@ -210,7 +215,7 @@ public boolean isEmpty() {
|
|||||||
return lockMode == LockMode.NONE
|
return lockMode == LockMode.NONE
|
||||||
&& timeout == WAIT_FOREVER
|
&& timeout == WAIT_FOREVER
|
||||||
&& followOnLocking == null
|
&& followOnLocking == null
|
||||||
&& !extendedScope
|
&& pessimisticLockScope == NORMAL
|
||||||
&& !hasAliasSpecificLockModes();
|
&& !hasAliasSpecificLockModes();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -232,7 +237,7 @@ public LockMode getLockMode() {
|
|||||||
*/
|
*/
|
||||||
public LockOptions setLockMode(LockMode lockMode) {
|
public LockOptions setLockMode(LockMode lockMode) {
|
||||||
if ( immutable ) {
|
if ( immutable ) {
|
||||||
throw new UnsupportedOperationException("immutable global instance of LockMode");
|
throw new UnsupportedOperationException("immutable global instance of LockOptions");
|
||||||
}
|
}
|
||||||
this.lockMode = lockMode;
|
this.lockMode = lockMode;
|
||||||
return this;
|
return this;
|
||||||
@ -249,7 +254,7 @@ public LockOptions setLockMode(LockMode lockMode) {
|
|||||||
*/
|
*/
|
||||||
public LockOptions setAliasSpecificLockMode(String alias, LockMode lockMode) {
|
public LockOptions setAliasSpecificLockMode(String alias, LockMode lockMode) {
|
||||||
if ( immutable ) {
|
if ( immutable ) {
|
||||||
throw new UnsupportedOperationException("immutable global instance of LockMode");
|
throw new UnsupportedOperationException("immutable global instance of LockOptions");
|
||||||
}
|
}
|
||||||
if ( aliasSpecificLockModes == null ) {
|
if ( aliasSpecificLockModes == null ) {
|
||||||
aliasSpecificLockModes = new LinkedHashMap<>();
|
aliasSpecificLockModes = new LinkedHashMap<>();
|
||||||
@ -413,7 +418,7 @@ public LockOptions setTimeOut(int timeout) {
|
|||||||
* @return the current {@link PessimisticLockScope}
|
* @return the current {@link PessimisticLockScope}
|
||||||
*/
|
*/
|
||||||
public PessimisticLockScope getLockScope() {
|
public PessimisticLockScope getLockScope() {
|
||||||
return extendedScope ? PessimisticLockScope.EXTENDED : PessimisticLockScope.NORMAL;
|
return pessimisticLockScope;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -430,49 +435,9 @@ public PessimisticLockScope getLockScope() {
|
|||||||
*/
|
*/
|
||||||
public LockOptions setLockScope(PessimisticLockScope scope) {
|
public LockOptions setLockScope(PessimisticLockScope scope) {
|
||||||
if ( immutable ) {
|
if ( immutable ) {
|
||||||
throw new UnsupportedOperationException("immutable global instance of LockMode");
|
throw new UnsupportedOperationException("immutable global instance of LockOptions");
|
||||||
}
|
}
|
||||||
return setScope(scope==PessimisticLockScope.EXTENDED);
|
pessimisticLockScope = scope;
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The current lock scope setting:
|
|
||||||
* <ul>
|
|
||||||
* <li>{@code true} means the lock extends to rows of owned
|
|
||||||
* collections, but
|
|
||||||
* <li>{@code false} means only the entity table and secondary
|
|
||||||
* tables are locked.
|
|
||||||
* </ul>
|
|
||||||
*
|
|
||||||
* @return {@code true} if the lock extends to owned associations
|
|
||||||
*
|
|
||||||
* @deprecated use {@link #getLockScope()}
|
|
||||||
*/
|
|
||||||
@Deprecated(since = "6.2", forRemoval = true)
|
|
||||||
public boolean getScope() {
|
|
||||||
return extendedScope;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the lock scope setting:
|
|
||||||
* <ul>
|
|
||||||
* <li>{@code true} means the lock extends to rows of owned
|
|
||||||
* collections, but
|
|
||||||
* <li>{@code false} means only the entity table and secondary
|
|
||||||
* tables are locked.
|
|
||||||
* </ul>
|
|
||||||
*
|
|
||||||
* @param scope the new scope setting
|
|
||||||
* @return {@code this} for method chaining
|
|
||||||
*
|
|
||||||
* @deprecated use {@link #setLockScope(PessimisticLockScope)}
|
|
||||||
*/
|
|
||||||
@Deprecated(since = "6.2", forRemoval = true)
|
|
||||||
public LockOptions setScope(boolean scope) {
|
|
||||||
if ( immutable ) {
|
|
||||||
throw new UnsupportedOperationException("immutable global instance of LockMode");
|
|
||||||
}
|
|
||||||
this.extendedScope = scope;
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -505,7 +470,7 @@ public Boolean getFollowOnLocking() {
|
|||||||
*/
|
*/
|
||||||
public LockOptions setFollowOnLocking(Boolean followOnLocking) {
|
public LockOptions setFollowOnLocking(Boolean followOnLocking) {
|
||||||
if ( immutable ) {
|
if ( immutable ) {
|
||||||
throw new UnsupportedOperationException("immutable global instance of LockMode");
|
throw new UnsupportedOperationException("immutable global instance of LockOptions");
|
||||||
}
|
}
|
||||||
this.followOnLocking = followOnLocking;
|
this.followOnLocking = followOnLocking;
|
||||||
return this;
|
return this;
|
||||||
@ -544,7 +509,7 @@ public LockOptions makeDefensiveCopy() {
|
|||||||
*/
|
*/
|
||||||
public void overlay(LockOptions lockOptions) {
|
public void overlay(LockOptions lockOptions) {
|
||||||
setLockMode( lockOptions.getLockMode() );
|
setLockMode( lockOptions.getLockMode() );
|
||||||
setScope( lockOptions.getScope() );
|
setLockScope( lockOptions.getLockScope() );
|
||||||
setTimeOut( lockOptions.getTimeOut() );
|
setTimeOut( lockOptions.getTimeOut() );
|
||||||
if ( lockOptions.aliasSpecificLockModes != null ) {
|
if ( lockOptions.aliasSpecificLockModes != null ) {
|
||||||
lockOptions.aliasSpecificLockModes.forEach(this::setAliasSpecificLockMode);
|
lockOptions.aliasSpecificLockModes.forEach(this::setAliasSpecificLockMode);
|
||||||
@ -563,7 +528,7 @@ public void overlay(LockOptions lockOptions) {
|
|||||||
*/
|
*/
|
||||||
public static LockOptions copy(LockOptions source, LockOptions destination) {
|
public static LockOptions copy(LockOptions source, LockOptions destination) {
|
||||||
destination.setLockMode( source.getLockMode() );
|
destination.setLockMode( source.getLockMode() );
|
||||||
destination.setScope( source.getScope() );
|
destination.setLockScope( source.getLockScope() );
|
||||||
destination.setTimeOut( source.getTimeOut() );
|
destination.setTimeOut( source.getTimeOut() );
|
||||||
if ( source.aliasSpecificLockModes != null ) {
|
if ( source.aliasSpecificLockModes != null ) {
|
||||||
destination.aliasSpecificLockModes = new HashMap<>( source.aliasSpecificLockModes );
|
destination.aliasSpecificLockModes = new HashMap<>( source.aliasSpecificLockModes );
|
||||||
@ -582,7 +547,7 @@ else if ( !(object instanceof LockOptions that) ) {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return timeout == that.timeout
|
return timeout == that.timeout
|
||||||
&& extendedScope == that.extendedScope
|
&& pessimisticLockScope == that.pessimisticLockScope
|
||||||
&& lockMode == that.lockMode
|
&& lockMode == that.lockMode
|
||||||
&& Objects.equals( aliasSpecificLockModes, that.aliasSpecificLockModes )
|
&& Objects.equals( aliasSpecificLockModes, that.aliasSpecificLockModes )
|
||||||
&& Objects.equals( followOnLocking, that.followOnLocking );
|
&& Objects.equals( followOnLocking, that.followOnLocking );
|
||||||
@ -591,6 +556,6 @@ else if ( !(object instanceof LockOptions that) ) {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hash( lockMode, timeout, aliasSpecificLockModes, followOnLocking, extendedScope);
|
return Objects.hash( lockMode, timeout, aliasSpecificLockModes, followOnLocking, pessimisticLockScope );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user