HHH-15681 use enum instead of boolean of lock scopes

also a bunch of Javadoc improvement for LockOptions and friends
This commit is contained in:
Gavin King 2022-11-07 02:15:18 +01:00
parent a5fa3739e2
commit 4b7fcb5123
13 changed files with 276 additions and 180 deletions

View File

@ -24,14 +24,15 @@ import jakarta.persistence.LockModeType;
*/
public enum LockMode {
/**
* No lock required. If an object is requested with this lock
* mode, a {@link #READ} lock will be obtained if it is
* necessary to actually read the state from the database,
* No lock required. If an object is requested with this
* lock mode, a {@link #READ} lock will be obtained if it
* is necessary to actually read the state from the database,
* rather than pull it from a cache.
* <p>
* This is the "default" lock mode.
*/
NONE( 0, "none" ),
/**
* A shared lock. Objects in this lock mode were read from
* the database in the current transaction, rather than being
@ -40,31 +41,34 @@ public enum LockMode {
READ( 5, "read" ),
/**
* Optimistically assume that transaction will not experience contention for
* entities. The entity version will be verified near the transaction end.
* Optimistically assume that transaction will not experience
* contention for an entity. The version will be verified near
* the transaction end.
*/
OPTIMISTIC( 6, "optimistic" ),
/**
* Optimistically assume that transaction will not experience contention for
* entities. The entity version will be verified and incremented near the transaction end.
* Optimistically assume that transaction will not experience
* contention for an entity. The version will be verified and
* incremented near the transaction end.
*/
OPTIMISTIC_FORCE_INCREMENT( 7, "optimistic_force_increment" ),
/**
* A {@code WRITE} lock is obtained when an object is updated or inserted.
*
* This lock mode is for internal use only and is not a valid mode for
* {@code load()} or {@code lock()}, both of which throw exceptions if
* {@code WRITE} is specified.
* A {@code WRITE} lock is obtained when an object is updated
* or inserted.
* <p>
* This lock mode is for internal use only and is not a valid
* argument to {@code load()} or {@code lock()}. These method
* throw an exception if {@code WRITE} given as an argument.
*/
@Internal
WRITE( 10, "write" ),
/**
* Attempt to obtain an upgrade lock, using an Oracle-style
* {@code select for update nowait}. The semantics of
* this lock mode, once obtained, are the same as
* {@code select for update nowait}. The semantics of this
* lock mode, once obtained, are the same as
* {@link #PESSIMISTIC_WRITE}.
*/
UPGRADE_NOWAIT( 10, "upgrade-nowait" ),
@ -78,7 +82,7 @@ public enum LockMode {
UPGRADE_SKIPLOCKED( 10, "upgrade-skiplocked" ),
/**
* Implemented as PESSIMISTIC_WRITE.
* Implemented as {@link #PESSIMISTIC_WRITE}.
*/
PESSIMISTIC_READ( 12, "pessimistic_read" ),

View File

@ -12,98 +12,130 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Objects;
import jakarta.persistence.PessimisticLockScope;
import org.hibernate.query.Query;
import org.hibernate.query.spi.QueryOptions;
import static java.util.Collections.emptyList;
/**
* Contains locking details (LockMode, Timeout and Scope).
*
* Contains a set of options describing how a row of a database table
* mapped by an entity should be locked. For
* {@link Session#buildLockRequest(LockOptions)},
* {@link Session#get(Class, Object, LockOptions)}, or
* {@link Session#refresh(Object, LockOptions)}, the relevant options
* are:
* <ul>
* <li>the {@link #getLockMode() lock mode},
* <li>the {@link #getTimeOut() pessimistic lock timeout}, and
* <li>the {@link #getLockScope() lock scope}, that is, whether the
* lock extends to rows of owned collections.
* </ul>
* In HQL and criteria queries, lock modes can be defined in an even
* more granular fashion, with the option to specify a lock mode that
* {@linkplain #setAliasSpecificLockMode(String, LockMode) applies
* only to a certain query alias}.
*
* @author Scott Marlow
*/
public class LockOptions implements Serializable {
/**
* Represents LockMode.NONE (timeout + scope do not apply).
* Represents {@link LockMode#NONE}, where timeout and scope are
* not applicable.
*/
public static final LockOptions NONE = new LockOptions(LockMode.NONE);
/**
* Represents LockMode.READ (timeout + scope do not apply).
* Represents {@link LockMode#READ}, where timeout and scope are
* not applicable.
*/
public static final LockOptions READ = new LockOptions(LockMode.READ);
/**
* Represents LockMode.UPGRADE (will wait forever for lock and scope of false meaning only entity is locked).
* Represents {@link LockMode#PESSIMISTIC_WRITE} with
* {@linkplain #WAIT_FOREVER no timeout}, and
* {@linkplain PessimisticLockScope#NORMAL no extension of the
* lock to owned collections}.
*/
public static final LockOptions UPGRADE = new LockOptions(LockMode.PESSIMISTIC_WRITE);
/**
* Indicates that the database should not wait at all to acquire the pessimistic lock.
* Indicates that the database should not wait at all to acquire
* a pessimistic lock which is not immediately available.
*
* @see #getTimeOut
*/
public static final int NO_WAIT = 0;
/**
* Indicates that there is no timeout for the acquisition.
* Indicates that there is no timeout for the lock acquisition.
*
* @see #getTimeOut
*/
public static final int WAIT_FOREVER = -1;
/**
* Indicates that rows that are already locked should be skipped.
* Indicates that rows which are already locked should be skipped.
*
* @see #getTimeOut()
*/
public static final int SKIP_LOCKED = -2;
private LockMode lockMode = LockMode.NONE;
private int timeout = WAIT_FOREVER;
private boolean scope;
private Map<String,LockMode> aliasSpecificLockModes;
private Boolean followOnLocking;
/**
* Constructs a LockOptions with all default options.
* Constructs an instance with all default options.
*/
public LockOptions() {
}
/**
* Constructs a LockOptions with the given lock mode.
* Constructs an instance with the given {@linkplain LockMode
* lock mode}.
*
* @param lockMode The lock mode to use
*/
public LockOptions( LockMode lockMode) {
public LockOptions(LockMode lockMode) {
this.lockMode = lockMode;
}
/**
* Returns whether the lock options are empty.
* Determine of the lock options are empty.
*
* @return If the lock options is equivalent to {@link LockOptions#NONE}.
* @return {@code true} if the lock options are equivalent to
* {@link LockOptions#NONE}.
*/
public boolean isEmpty() {
return lockMode == LockMode.NONE && timeout == WAIT_FOREVER && followOnLocking == null && !scope && !hasAliasSpecificLockModes();
return lockMode == LockMode.NONE
&& timeout == WAIT_FOREVER
&& followOnLocking == null
&& !scope
&& !hasAliasSpecificLockModes();
}
/**
* Retrieve the overall lock mode in effect for this set of options.
* <p/>
* In certain contexts (hql and criteria), lock-modes can be defined in an
* even more granular {@link #setAliasSpecificLockMode(String, LockMode) per-alias} fashion
*
* @return The overall lock mode.
* @return the overall lock mode
*/
public LockMode getLockMode() {
return lockMode;
}
/**
* Set the overall {@link LockMode} to be used. The default is
* {@link LockMode#NONE}
* Set the overall {@linkplain LockMode lock mode}. The default is
* {@link LockMode#NONE}, that is, no locking at all.
*
* @param lockMode The new overall lock mode to use.
*
* @return this (for method chaining).
* @param lockMode the new overall lock mode
* @return {@code this} for method chaining
*/
public LockOptions setLockMode(LockMode lockMode) {
this.lockMode = lockMode;
@ -111,11 +143,11 @@ public class LockOptions implements Serializable {
}
/**
* Specify the {@link LockMode} to be used for a specific query alias.
* Specify the {@link LockMode} to be used for the given query alias.
*
* @param alias used to reference the LockMode.
* @param lockMode The lock mode to apply to the given alias
* @return this LockRequest instance for operation chaining.
* @param alias the query alias to which the lock mode applies
* @param lockMode the lock mode to apply to the given alias
* @return {@code this} for method chaining
*
* @see Query#setLockMode(String, LockMode)
*/
@ -133,34 +165,30 @@ public class LockOptions implements Serializable {
}
/**
* Get the {@link LockMode} explicitly specified for the given alias via
* {@link #setAliasSpecificLockMode}
* <p/>
* Differs from {@link #getEffectiveLockMode} in that here we only return
* explicitly specified alias-specific lock modes.
* Get the {@link LockMode} explicitly specified for the given alias
* via {@link #setAliasSpecificLockMode(String, LockMode)}.
* <p>
* Differs from {@link #getEffectiveLockMode(String)} in that here we
* only return an explicitly specified alias-specific lock mode.
*
* @param alias The alias for which to locate the explicit lock mode.
*
* @return The explicit lock mode for that alias.
*/
public LockMode getAliasSpecificLockMode(String alias) {
if ( aliasSpecificLockModes == null ) {
return null;
}
return aliasSpecificLockModes.get( alias );
return aliasSpecificLockModes == null ? null : aliasSpecificLockModes.get( alias );
}
/**
* Determine the {@link LockMode} to apply to the given alias. If no
* mode was explicitly {@linkplain #setAliasSpecificLockMode set}, the
* {@linkplain #getLockMode overall mode} is returned. If the overall
* lock mode is {@code null} as well, {@link LockMode#NONE} is returned.
* <p/>
* Differs from {@link #getAliasSpecificLockMode} in that here we fallback to we only return
* the overall lock mode.
* Determine the {@link LockMode} to apply to the given alias. If no
* mode was {@linkplain #setAliasSpecificLockMode(String, LockMode)}
* explicitly set}, the {@linkplain #getLockMode()} overall mode} is
* returned. If the overall lock mode is also {@code null},
* {@link LockMode#NONE} is returned.
* <p>
* Differs from {@link #getAliasSpecificLockMode(String)} in that here
* we fall back to only returning the overall lock mode.
*
* @param alias The alias for which to locate the effective lock mode.
*
* @return The effective lock mode.
*/
public LockMode getEffectiveLockMode(String alias) {
@ -172,31 +200,31 @@ public class LockOptions implements Serializable {
}
/**
* Does this {@code LockOptions} instance define alias-specific lock modes?
* Does this {@code LockOptions} instance define alias-specific lock
* modes?
*
* @return {@code true} if this object defines alias-specific lock modes; {@code false} otherwise.
* @return {@code true} if this object defines alias-specific lock modes;
* {@code false} otherwise.
*/
public boolean hasAliasSpecificLockModes() {
return aliasSpecificLockModes != null
&& ! aliasSpecificLockModes.isEmpty();
&& ! aliasSpecificLockModes.isEmpty();
}
/**
* Get the number of aliases that have specific lock modes defined.
* The number of aliases that have alias-specific lock modes specified.
*
* @return the number of explicitly defined alias lock modes.
*/
public int getAliasLockCount() {
if ( aliasSpecificLockModes == null ) {
return 0;
}
return aliasSpecificLockModes.size();
return aliasSpecificLockModes == null ? 0 : aliasSpecificLockModes.size();
}
/**
* Iterator for accessing Alias (key) and LockMode (value) as Map.Entry.
* Iterator over {@link Map.Entry}s, each containing an alias and its
* {@link LockMode}.
*
* @return Iterator for accessing the Map.Entry's
* @return an iterator over the {@link Map.Entry}s
* @deprecated use {@link #getAliasSpecificLocks()}
*/
@Deprecated
@ -205,15 +233,13 @@ public class LockOptions implements Serializable {
}
/**
* Iterable access to alias (key) and LockMode (value) as Map.Entry.
* Iterable with {@link Map.Entry}s, each containing an alias and its
* {@link LockMode}.
*
* @return Iterable for accessing the Map.Entry's
* @return an iterable with the {@link Map.Entry}s
*/
public Iterable<Map.Entry<String,LockMode>> getAliasSpecificLocks() {
if ( aliasSpecificLockModes == null ) {
return Collections.emptyList();
}
return aliasSpecificLockModes.entrySet();
return aliasSpecificLockModes == null ? emptyList() : aliasSpecificLockModes.entrySet();
}
/**
@ -241,27 +267,30 @@ public class LockOptions implements Serializable {
}
/**
* Retrieve the current timeout setting.
* <p/>
* The timeout is the amount of time, in milliseconds, we should instruct the database
* to wait for any requested pessimistic lock acquisition.
* <p/>
* {@link #NO_WAIT}, {@link #WAIT_FOREVER} or {@link #SKIP_LOCKED} represent 3 "magic" values.
* The current timeout, a maximum amount of time in milliseconds
* that the database should wait to obtain a pessimistic lock before
* returning an error to the client.
* <p>
* {@link #NO_WAIT}, {@link #WAIT_FOREVER}, or {@link #SKIP_LOCKED}
* represent 3 "magic" values.
*
* @return timeout in milliseconds, {@link #NO_WAIT}, {@link #WAIT_FOREVER} or {@link #SKIP_LOCKED}
* @return a timeout in milliseconds, {@link #NO_WAIT},
* {@link #WAIT_FOREVER}, or {@link #SKIP_LOCKED}
*/
public int getTimeOut() {
return timeout;
}
/**
* Set the timeout setting.
* <p/>
* See {@link #getTimeOut} for a discussion of meaning.
* Set the timeout, that is, the maximum amount of time in milliseconds
* that the database should wait to obtain a pessimistic lock before
* returning an error to the client.
* <p>
* {@link #NO_WAIT}, {@link #WAIT_FOREVER}, or {@link #SKIP_LOCKED}
* represent 3 "magic" values.
*
* @param timeout The new timeout setting, in milliseconds
*
* @return this (for method chaining).
* @param timeout the new timeout setting, in milliseconds
* @return {@code this} for method chaining
*
* @see #getTimeOut
*/
@ -270,44 +299,93 @@ public class LockOptions implements Serializable {
return this;
}
private boolean scope;
/**
* The current lock scope:
* <ul>
* <li>{@link PessimisticLockScope#EXTENDED} means the lock
* extends to rows of owned collections, but
* <li>{@link PessimisticLockScope#NORMAL} means only the entity
* table and secondary tables are locked.
* </ul>
*
* @return the current {@link PessimisticLockScope}
*/
public PessimisticLockScope getLockScope() {
return scope ? PessimisticLockScope.EXTENDED : PessimisticLockScope.NORMAL;
}
/**
* Retrieve the current lock scope setting.
* <p/>
* "scope" is a JPA defined term. It is basically a cascading of the lock to associations.
* Set the lock scope:
* <ul>
* <li>{@link PessimisticLockScope#EXTENDED} means the lock
* extends to rows of owned collections, but
* <li>{@link PessimisticLockScope#NORMAL} means only the entity
* table and secondary tables are locked.
* </ul>
*
* @return true if locking will be extended to owned associations
* @param scope the new {@link PessimisticLockScope}
* @return {@code this} for method chaining
*/
public LockOptions setLockScope(PessimisticLockScope scope) {
return setScope(scope==PessimisticLockScope.EXTENDED);
}
/**
* 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")
public boolean getScope() {
return scope;
}
/**
* Set the scope.
* 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
* @param scope the new scope setting
* @return {@code this} for method chaining
*
* @return this (for method chaining).
* @deprecated use {@link #setLockScope(PessimisticLockScope)}
*/
@Deprecated(since = "6.2")
public LockOptions setScope(boolean scope) {
this.scope = scope;
return this;
}
/**
* Retrieve the current follow-on-locking setting.
* The current follow-on locking setting.
*
* @return true if follow-on-locking is enabled
* @return {@code true} if follow-on locking is enabled
*
* @see org.hibernate.dialect.Dialect#useFollowOnLocking(String, QueryOptions)
*/
public Boolean getFollowOnLocking() {
return followOnLocking;
}
/**
* Set the follow-on-locking setting.
* @param followOnLocking The new follow-on-locking setting
* @return this (for method chaining).
* Set the follow-on locking setting.
*
* @param followOnLocking The new follow-on locking setting
* @return {@code this} for method chaining
*
* @see org.hibernate.dialect.Dialect#useFollowOnLocking(String, QueryOptions)
*/
public LockOptions setFollowOnLocking(Boolean followOnLocking) {
this.followOnLocking = followOnLocking;
@ -330,7 +408,8 @@ public class LockOptions implements Serializable {
}
/**
* Perform a shallow copy.
* Copy the options in the first given instance of
* {@code LockOptions} to the second given instance.
*
* @param source Source for the copy (copied from)
* @param destination Destination for the copy (copied to)
@ -349,40 +428,25 @@ public class LockOptions implements Serializable {
}
@Override
public boolean equals(Object o) {
if ( this == o ) {
public boolean equals(Object object) {
if ( this == object ) {
return true;
}
if ( o == null || getClass() != o.getClass() ) {
else if ( !(object instanceof LockOptions) ) {
return false;
}
LockOptions that = (LockOptions) o;
if ( timeout != that.timeout ) {
return false;
else {
final LockOptions that = (LockOptions) object;
return timeout == that.timeout
&& scope == that.scope
&& lockMode == that.lockMode
&& Objects.equals( aliasSpecificLockModes, that.aliasSpecificLockModes )
&& Objects.equals( followOnLocking, that.followOnLocking );
}
if ( scope != that.scope ) {
return false;
}
if ( lockMode != that.lockMode ) {
return false;
}
if ( aliasSpecificLockModes != null ?
!aliasSpecificLockModes.equals( that.aliasSpecificLockModes ) :
that.aliasSpecificLockModes != null ) {
return false;
}
return followOnLocking != null ? followOnLocking.equals( that.followOnLocking ) : that.followOnLocking == null;
}
@Override
public int hashCode() {
int result = lockMode != null ? lockMode.hashCode() : 0;
result = 31 * result + timeout;
result = 31 * result + ( aliasSpecificLockModes != null ? aliasSpecificLockModes.hashCode() : 0 );
result = 31 * result + ( followOnLocking != null ? followOnLocking.hashCode() : 0 );
result = 31 * result + ( scope ? 1 : 0 );
return result;
return Objects.hash( lockMode, timeout, aliasSpecificLockModes, followOnLocking, scope );
}
}

View File

@ -8,6 +8,7 @@ package org.hibernate;
import java.util.List;
import jakarta.persistence.PessimisticLockScope;
import org.hibernate.graph.RootGraph;
import org.hibernate.query.Query;
import org.hibernate.stat.SessionStatistics;
@ -1209,13 +1210,13 @@ public interface Session extends SharedSessionContract, EntityManager {
*/
interface LockRequest {
/**
* Constant usable as a time out value that indicates no wait semantics should
* Constant usable as a timeout value indicating that no wait semantics should
* be used in attempting to acquire locks.
*/
int PESSIMISTIC_NO_WAIT = 0;
/**
* Constant usable as a time out value that indicates that attempting to acquire
* locks should be allowed to wait forever (apply no timeout).
* Constant usable as a timeout value indicating that attempting to acquire
* locks should be allowed to wait forever, that is, that there's no timeout.
*/
int PESSIMISTIC_WAIT_FOREVER = -1;
@ -1243,9 +1244,10 @@ public interface Session extends SharedSessionContract, EntityManager {
int getTimeOut();
/**
* Specify the pessimistic lock timeout. The default pessimistic lock behavior
* is to wait forever for the lock. Lock timeout support is not available in
* all {@link org.hibernate.dialect.Dialect SQL dialects}.
* Specify the pessimistic lock timeout. The default pessimistic lock
* behavior is to wait forever for the lock. Lock timeout support is
* not available in every {@link org.hibernate.dialect.Dialect dialect}
* of SQL.
*
* @param timeout is time in milliseconds to wait for lock.
* -1 means wait forever and 0 means no wait.
@ -1255,24 +1257,43 @@ public interface Session extends SharedSessionContract, EntityManager {
LockRequest setTimeOut(int timeout);
/**
* Check if locking is cascaded to owned collections and associated entities.
* Check if locking extends to owned collections and associated entities.
*
* @return true if locking will be extended to owned collections and associated entities
*
* @deprecated use {@link #getLockScope()}
*/
@Deprecated(since = "6.2")
boolean getScope();
/**
* Specify whether the {@link LockMode} should be cascaded to owned collections
* Check if locking extends to owned collections and associated entities.
*
* @return true if locking will be extended to owned collections and associated entities
*/
default PessimisticLockScope getLockScope() {
return getScope() ? PessimisticLockScope.EXTENDED : PessimisticLockScope.NORMAL;
}
/**
* Specify whether the {@link LockMode} should extend to owned collections
* and associated entities. An association must be mapped with
* {@link org.hibernate.annotations.CascadeType#LOCK} for this setting to have
* any effect.
* {@link org.hibernate.annotations.CascadeType#LOCK} for this setting to
* have any effect.
*
* @param scope {@code true} to cascade locks; {@code false} to not.
*
* @return {@code this}, for method chaining
*
* @deprecated use {@link #setLockScope(PessimisticLockScope)}
*/
@Deprecated(since = "6.2")
LockRequest setScope(boolean scope);
default LockRequest setLockScope(PessimisticLockScope scope) {
return setScope( scope == PessimisticLockScope.EXTENDED );
}
/**
* Perform the requested locking.
*

View File

@ -3258,7 +3258,7 @@ public abstract class Dialect implements ConversionContext {
}
/**
* Get the UniqueDelegate supported by this dialect
* Get the {@link UniqueDelegate} supported by this dialect
*
* @return The UniqueDelegate
*/

View File

@ -15,10 +15,11 @@ import org.hibernate.event.spi.EventSource;
import org.hibernate.persister.entity.Lockable;
/**
* An optimistic locking strategy that forces an increment of the version (after verifying that version hasn't changed).
* This takes place just prior to transaction commit.
* <p/>
* This strategy is valid for LockMode.OPTIMISTIC_FORCE_INCREMENT
* An optimistic locking strategy that verifies that the version
* has not changed and then forces an increment of the version,
* just before committing the transaction.
* <p>
* This strategy is valid for {@link LockMode#OPTIMISTIC_FORCE_INCREMENT}.
*
* @author Scott Marlow
* @since 3.5

View File

@ -14,9 +14,10 @@ import org.hibernate.event.spi.EventSource;
import org.hibernate.persister.entity.Lockable;
/**
* An optimistic locking strategy that verifies that the version hasn't changed (prior to transaction commit).
* An optimistic locking strategy that simply verifies that the
* version has not changed, just before committing the transaction.
* <p/>
* This strategy is valid for LockMode.OPTIMISTIC
* This strategy is valid for {@link LockMode#OPTIMISTIC}.
*
* @author Scott Marlow
* @since 3.5

View File

@ -14,9 +14,10 @@ import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.persister.entity.Lockable;
/**
* A pessimistic locking strategy that increments the version immediately (obtaining an exclusive write lock).
* <p/>
* This strategy is valid for LockMode.PESSIMISTIC_FORCE_INCREMENT
* A pessimistic locking strategy where a lock is obtained by incrementing
* the version immediately, obtaining an exclusive write lock by side effect.
* <p>
* This strategy is valid for {@link LockMode#PESSIMISTIC_FORCE_INCREMENT}.
*
* @author Scott Marlow
* @since 3.5

View File

@ -23,14 +23,15 @@ import org.hibernate.sql.SimpleSelect;
import org.hibernate.stat.spi.StatisticsImplementor;
/**
* A pessimistic locking strategy where the locks are obtained through select statements.
* <p/>
* For non-read locks, this is achieved through the Dialect's specific
* SELECT ... FOR UPDATE syntax.
*
* This strategy is valid for LockMode.PESSIMISTIC_READ
*
* This class is a clone of SelectLockingStrategy.
* A pessimistic locking strategy where a lock is obtained via a
* select statements.
* <p>
* For non-read locks, this is achieved through the dialect's native
* {@code SELECT ... FOR UPDATE} syntax.
* <p>
* This strategy is valid for {@link LockMode#PESSIMISTIC_READ}.
* <p>
* This class is a clone of {@link SelectLockingStrategy}.
*
* @author Steve Ebersole
* @author Scott Marlow

View File

@ -25,11 +25,12 @@ import org.hibernate.stat.spi.StatisticsImplementor;
import org.jboss.logging.Logger;
/**
* A pessimistic locking strategy where the locks are obtained through update statements.
* <p/>
* This strategy is valid for LockMode.PESSIMISTIC_READ
*
* This class is a clone of UpdateLockingStrategy.
* A pessimistic locking strategy where a lock is obtained via
* an update statement.
* <p>
* This strategy is valid for {@link LockMode#PESSIMISTIC_READ}.
* <p>
* This class is a clone of {@link UpdateLockingStrategy}.
*
* @author Steve Ebersole
* @author Scott Marlow

View File

@ -23,14 +23,15 @@ import org.hibernate.sql.SimpleSelect;
import org.hibernate.stat.spi.StatisticsImplementor;
/**
* A pessimistic locking strategy where the locks are obtained through select statements.
* <p/>
* For non-read locks, this is achieved through the Dialect's specific
* SELECT ... FOR UPDATE syntax.
*
* This strategy is valid for LockMode.PESSIMISTIC_WRITE
*
* This class is a clone of SelectLockingStrategy.
* A pessimistic locking strategy where a lock is obtained via a
* select statement.
* <p>
* For non-read locks, this is achieved through the dialect's native
* {@code SELECT ... FOR UPDATE} syntax.
* <p>
* This strategy is valid for {@link LockMode#PESSIMISTIC_WRITE}.
* <p>
* This class is a clone of {@link SelectLockingStrategy}.
*
* @see org.hibernate.dialect.Dialect#getForUpdateString(LockMode)
* @see org.hibernate.dialect.Dialect#appendLockHint(LockOptions, String)

View File

@ -25,11 +25,12 @@ import org.hibernate.stat.spi.StatisticsImplementor;
import org.jboss.logging.Logger;
/**
* A pessimistic locking strategy where the locks are obtained through update statements.
* <p/>
* This strategy is valid for LockMode.PESSIMISTIC_WRITE
*
* This class is a clone of UpdateLockingStrategy.
* A pessimistic locking strategy where a lock is obtained via
* an update statement.
* <p>
* This strategy is valid for {@link LockMode#PESSIMISTIC_WRITE}.
* <p>
* This class is a clone of {@link UpdateLockingStrategy}.
*
* @author Steve Ebersole
* @author Scott Marlow

View File

@ -23,10 +23,10 @@ import org.hibernate.sql.SimpleSelect;
import org.hibernate.stat.spi.StatisticsImplementor;
/**
* A locking strategy where the locks are obtained through select statements.
* A locking strategy where a lock is obtained via a select statement.
* <p/>
* For non-read locks, this is achieved through the Dialect's specific
* SELECT ... FOR UPDATE syntax.
* For non-read locks, this is achieved through the dialect's native
* {@code SELECT ... FOR UPDATE} syntax.
*
* @see org.hibernate.dialect.Dialect#getForUpdateString(LockMode)
* @see org.hibernate.dialect.Dialect#appendLockHint(LockOptions, String)

View File

@ -27,8 +27,8 @@ import org.hibernate.type.Type;
import org.jboss.logging.Logger;
/**
* A locking strategy where the locks are obtained through update statements.
* <p/>
* A locking strategy where a lock is obtained via an update statement.
* <p>
* This strategy is not valid for read style locks.
*
* @author Steve Ebersole