Package org.hibernate
Enum Class Locking.Scope
- All Implemented Interfaces:
FindOption
,LockOption
,RefreshOption
,Serializable
,Comparable<Locking.Scope>
,Constable
- Enclosing interface:
Locking
public static enum Locking.Scope
extends Enum<Locking.Scope>
implements FindOption, LockOption, RefreshOption
When pessimistic locking is requested, this enum defines
what exactly will be locked.
- See Also:
- API Note:
- Same intention as the JPA PessimisticLockScope, but offering the additional INCLUDE_FETCHES behavior.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionIn addition to the locking behavior specified for ROOT_ONLY, rows for collection tables (ElementCollection, OneToMany and ManyToMany) will also be locked.All tables with fetched rows will be locked.Lock the database row(s) that correspond to the non-collection-valued persistent state of that instance. -
Method Summary
Modifier and TypeMethodDescriptionstatic Locking.Scope
fromJpaScope
(PessimisticLockScope scope) The JPA PessimisticLockScope which corresponds to this Scope.static Locking.Scope
static Locking.Scope
Returns the enum constant of this class with the specified name.static Locking.Scope[]
values()
Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
ROOT_ONLY
Lock the database row(s) that correspond to the non-collection-valued persistent state of that instance. If a joined inheritance strategy is used, or if the entity is otherwise mapped to a secondary table, this entails locking the row(s) for the entity instance in the additional table(s).- See Also:
-
INCLUDE_COLLECTIONS
In addition to the locking behavior specified for ROOT_ONLY, rows for collection tables (ElementCollection, OneToMany and ManyToMany) will also be locked. Hibernate will only lock these collection rows when they are joined. The alternatives would be to either:-
Add joins for the collection tables, which is problematic because
- if
inner joins
are added, the results will be unexpectedly affected - if
outer joins
are added, many databases do not allow locking outer joins
- if
- Perform follow-on locking which can lead to deadlocks.
- See Also:
- API Note:
- Locking only joined rows is arguably not fully compliant with the specification. However, we believe it is the best implementation.
-
Add joins for the collection tables, which is problematic because
-
INCLUDE_FETCHES
All tables with fetched rows will be locked.- API Note:
- This is Hibernate's legacy behavior, and has no corresponding JPA scope.
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum class has no constant with the specified nameNullPointerException
- if the argument is null
-
getCorrespondingJpaScope
The JPA PessimisticLockScope which corresponds to this Scope.- Returns:
- The corresponding PessimisticLockScope, or
null
.
-
fromJpaScope
-
interpret
-