avoid use of deprecated methods
Signed-off-by: Gavin King <gavin@hibernate.org>
This commit is contained in:
parent
f95182e736
commit
335f7bea9c
|
@ -140,7 +140,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 scope;
|
private boolean extendedScope;
|
||||||
private Boolean followOnLocking;
|
private Boolean followOnLocking;
|
||||||
private Map<String, LockMode> aliasSpecificLockModes;
|
private Map<String, LockMode> aliasSpecificLockModes;
|
||||||
|
|
||||||
|
@ -191,7 +191,7 @@ public class LockOptions implements FindOption, RefreshOption, Serializable {
|
||||||
immutable = false;
|
immutable = false;
|
||||||
this.lockMode = lockMode;
|
this.lockMode = lockMode;
|
||||||
this.timeout = timeout;
|
this.timeout = timeout;
|
||||||
this.scope = scope == PessimisticLockScope.EXTENDED;
|
this.extendedScope = scope == PessimisticLockScope.EXTENDED;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -212,7 +212,7 @@ public class LockOptions implements FindOption, RefreshOption, Serializable {
|
||||||
return lockMode == LockMode.NONE
|
return lockMode == LockMode.NONE
|
||||||
&& timeout == WAIT_FOREVER
|
&& timeout == WAIT_FOREVER
|
||||||
&& followOnLocking == null
|
&& followOnLocking == null
|
||||||
&& !scope
|
&& !extendedScope
|
||||||
&& !hasAliasSpecificLockModes();
|
&& !hasAliasSpecificLockModes();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -415,7 +415,7 @@ public class LockOptions implements FindOption, RefreshOption, Serializable {
|
||||||
* @return the current {@link PessimisticLockScope}
|
* @return the current {@link PessimisticLockScope}
|
||||||
*/
|
*/
|
||||||
public PessimisticLockScope getLockScope() {
|
public PessimisticLockScope getLockScope() {
|
||||||
return scope ? PessimisticLockScope.EXTENDED : PessimisticLockScope.NORMAL;
|
return extendedScope ? PessimisticLockScope.EXTENDED : PessimisticLockScope.NORMAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -450,9 +450,9 @@ public class LockOptions implements FindOption, RefreshOption, Serializable {
|
||||||
*
|
*
|
||||||
* @deprecated use {@link #getLockScope()}
|
* @deprecated use {@link #getLockScope()}
|
||||||
*/
|
*/
|
||||||
@Deprecated(since = "6.2")
|
@Deprecated(since = "6.2", forRemoval = true)
|
||||||
public boolean getScope() {
|
public boolean getScope() {
|
||||||
return scope;
|
return extendedScope;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -469,12 +469,12 @@ public class LockOptions implements FindOption, RefreshOption, Serializable {
|
||||||
*
|
*
|
||||||
* @deprecated use {@link #setLockScope(PessimisticLockScope)}
|
* @deprecated use {@link #setLockScope(PessimisticLockScope)}
|
||||||
*/
|
*/
|
||||||
@Deprecated(since = "6.2")
|
@Deprecated(since = "6.2", forRemoval = true)
|
||||||
public LockOptions setScope(boolean scope) {
|
public LockOptions setScope(boolean scope) {
|
||||||
if ( immutable ) {
|
if ( immutable ) {
|
||||||
throw new UnsupportedOperationException("immutable global instance of LockMode");
|
throw new UnsupportedOperationException("immutable global instance of LockMode");
|
||||||
}
|
}
|
||||||
this.scope = scope;
|
this.extendedScope = scope;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -579,13 +579,12 @@ public class LockOptions implements FindOption, RefreshOption, Serializable {
|
||||||
if ( this == object ) {
|
if ( this == object ) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if ( !(object instanceof LockOptions) ) {
|
else if ( !(object instanceof LockOptions that) ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
final LockOptions that = (LockOptions) object;
|
|
||||||
return timeout == that.timeout
|
return timeout == that.timeout
|
||||||
&& scope == that.scope
|
&& extendedScope == that.extendedScope
|
||||||
&& 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 );
|
||||||
|
@ -594,6 +593,6 @@ public class LockOptions implements FindOption, RefreshOption, Serializable {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hash( lockMode, timeout, aliasSpecificLockModes, followOnLocking, scope );
|
return Objects.hash( lockMode, timeout, aliasSpecificLockModes, followOnLocking, extendedScope);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
*/
|
*/
|
||||||
package org.hibernate.event.spi;
|
package org.hibernate.event.spi;
|
||||||
|
|
||||||
|
import jakarta.persistence.PessimisticLockScope;
|
||||||
import org.hibernate.LockMode;
|
import org.hibernate.LockMode;
|
||||||
import org.hibernate.LockOptions;
|
import org.hibernate.LockOptions;
|
||||||
|
|
||||||
|
@ -130,11 +131,11 @@ public class LoadEvent extends AbstractEvent {
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getLockTimeout() {
|
public int getLockTimeout() {
|
||||||
return this.lockOptions.getTimeOut();
|
return lockOptions.getTimeOut();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getLockScope() {
|
public boolean getLockScope() {
|
||||||
return this.lockOptions.getScope();
|
return lockOptions.getLockScope() == PessimisticLockScope.EXTENDED;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object getResult() {
|
public Object getResult() {
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
*/
|
*/
|
||||||
package org.hibernate.event.spi;
|
package org.hibernate.event.spi;
|
||||||
|
|
||||||
|
import jakarta.persistence.PessimisticLockScope;
|
||||||
import org.hibernate.LockMode;
|
import org.hibernate.LockMode;
|
||||||
import org.hibernate.LockOptions;
|
import org.hibernate.LockOptions;
|
||||||
|
|
||||||
|
@ -63,7 +64,7 @@ public class LockEvent extends AbstractEvent {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getLockScope() {
|
public boolean getLockScope() {
|
||||||
return lockOptions.getScope();
|
return lockOptions.getLockScope() == PessimisticLockScope.EXTENDED;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getEntityName() {
|
public String getEntityName() {
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
*/
|
*/
|
||||||
package org.hibernate.event.spi;
|
package org.hibernate.event.spi;
|
||||||
|
|
||||||
|
import jakarta.persistence.PessimisticLockScope;
|
||||||
import org.hibernate.LockMode;
|
import org.hibernate.LockMode;
|
||||||
import org.hibernate.LockOptions;
|
import org.hibernate.LockOptions;
|
||||||
|
|
||||||
|
@ -80,10 +81,10 @@ public class RefreshEvent extends AbstractEvent {
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getLockTimeout() {
|
public int getLockTimeout() {
|
||||||
return this.lockOptions.getTimeOut();
|
return lockOptions.getTimeOut();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getLockScope() {
|
public boolean getLockScope() {
|
||||||
return this.lockOptions.getScope();
|
return lockOptions.getLockScope() == PessimisticLockScope.EXTENDED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@ import jakarta.persistence.PessimisticLockScope;
|
||||||
import org.hibernate.LockOptions;
|
import org.hibernate.LockOptions;
|
||||||
|
|
||||||
import static jakarta.persistence.PessimisticLockScope.EXTENDED;
|
import static jakarta.persistence.PessimisticLockScope.EXTENDED;
|
||||||
|
import static jakarta.persistence.PessimisticLockScope.NORMAL;
|
||||||
import static org.hibernate.cfg.AvailableSettings.JAKARTA_LOCK_SCOPE;
|
import static org.hibernate.cfg.AvailableSettings.JAKARTA_LOCK_SCOPE;
|
||||||
import static org.hibernate.cfg.AvailableSettings.JAKARTA_LOCK_TIMEOUT;
|
import static org.hibernate.cfg.AvailableSettings.JAKARTA_LOCK_TIMEOUT;
|
||||||
import static org.hibernate.cfg.AvailableSettings.JPA_LOCK_SCOPE;
|
import static org.hibernate.cfg.AvailableSettings.JPA_LOCK_SCOPE;
|
||||||
|
@ -47,10 +48,10 @@ final class LockOptionsHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( lockScope instanceof String string ) {
|
if ( lockScope instanceof String string ) {
|
||||||
lockOptions.get().setScope( EXTENDED.name().equalsIgnoreCase( string ) );
|
lockOptions.get().setLockScope( EXTENDED.name().equalsIgnoreCase( string ) ? EXTENDED : NORMAL );
|
||||||
}
|
}
|
||||||
else if ( lockScope instanceof PessimisticLockScope ) {
|
else if ( lockScope instanceof PessimisticLockScope pessimisticLockScope ) {
|
||||||
lockOptions.get().setScope( EXTENDED == lockScope );
|
lockOptions.get().setLockScope( pessimisticLockScope );
|
||||||
}
|
}
|
||||||
else if ( lockScope != null ) {
|
else if ( lockScope != null ) {
|
||||||
throw new PersistenceException( "Unable to parse " + lockScopeHint + ": " + lockScope );
|
throw new PersistenceException( "Unable to parse " + lockScopeHint + ": " + lockScope );
|
||||||
|
|
|
@ -22,6 +22,7 @@ import jakarta.persistence.EntityGraph;
|
||||||
import jakarta.persistence.FlushModeType;
|
import jakarta.persistence.FlushModeType;
|
||||||
import jakarta.persistence.LockModeType;
|
import jakarta.persistence.LockModeType;
|
||||||
import jakarta.persistence.Parameter;
|
import jakarta.persistence.Parameter;
|
||||||
|
import jakarta.persistence.PessimisticLockScope;
|
||||||
import jakarta.persistence.TemporalType;
|
import jakarta.persistence.TemporalType;
|
||||||
|
|
||||||
import org.hibernate.CacheMode;
|
import org.hibernate.CacheMode;
|
||||||
|
@ -349,7 +350,7 @@ public abstract class AbstractQuery<R>
|
||||||
hints.put( HINT_JAVAEE_LOCK_TIMEOUT, getLockOptions().getTimeOut() );
|
hints.put( HINT_JAVAEE_LOCK_TIMEOUT, getLockOptions().getTimeOut() );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( getLockOptions().getScope() ) {
|
if ( getLockOptions().getLockScope() == PessimisticLockScope.EXTENDED ) {
|
||||||
hints.put( HINT_SPEC_LOCK_SCOPE, getLockOptions().getLockScope() );
|
hints.put( HINT_SPEC_LOCK_SCOPE, getLockOptions().getLockScope() );
|
||||||
hints.put( HINT_JAVAEE_LOCK_SCOPE, getLockOptions().getLockScope() );
|
hints.put( HINT_JAVAEE_LOCK_SCOPE, getLockOptions().getLockScope() );
|
||||||
}
|
}
|
||||||
|
|
|
@ -113,7 +113,7 @@ public class DeferredResultSetAccess extends AbstractResultSetAccess {
|
||||||
|
|
||||||
final LockOptions lockOptionsToUse = new LockOptions( lockMode );
|
final LockOptions lockOptionsToUse = new LockOptions( lockMode );
|
||||||
lockOptionsToUse.setTimeOut( lockOptions.getTimeOut() );
|
lockOptionsToUse.setTimeOut( lockOptions.getTimeOut() );
|
||||||
lockOptionsToUse.setScope( lockOptions.getScope() );
|
lockOptionsToUse.setLockScope( lockOptions.getLockScope() );
|
||||||
|
|
||||||
executionContext.getCallback().registerAfterLoadAction( (entity, persister, session) ->
|
executionContext.getCallback().registerAfterLoadAction( (entity, persister, session) ->
|
||||||
session.asSessionImplementor().lock(
|
session.asSessionImplementor().lock(
|
||||||
|
|
Loading…
Reference in New Issue