Skip to content

Package: PessimisticLockScope

PessimisticLockScope

nameinstructionbranchcomplexitylinemethod
static {...}
M: 15 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*
2: * Copyright (c) 2008, 2023 Oracle and/or its affiliates. All rights reserved.
3: *
4: * This program and the accompanying materials are made available under the
5: * terms of the Eclipse Public License v. 2.0 which is available at
6: * http://www.eclipse.org/legal/epl-2.0,
7: * or the Eclipse Distribution License v. 1.0 which is available at
8: * http://www.eclipse.org/org/documents/edl-v10.php.
9: *
10: * SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
11: */
12:
13: // Contributors:
14: // Linda DeMichiel - 2.1
15: // Linda DeMichiel - 2.0
16:
17: package jakarta.persistence;
18:
19: /**
20: *
21: * Defines the values of the {@code jakarta.persistence.lock.scope}
22: * property for pessimistic locking. This property may be passed as an
23: * argument to the methods of the {@link EntityManager}, {@link Query},
24: * and {@link TypedQuery} interfaces that allow lock modes to be specified
25: * or used with the {@link NamedQuery} annotation.
26: *
27: * @since 2.0
28: */
29: public enum PessimisticLockScope implements FindOption, RefreshOption, LockOption {
30:
31: /**
32: * This value defines the default behavior for pessimistic locking.
33: *
34: * <p>The persistence provider must lock the database row(s) that
35: * correspond to the non-collection-valued persistent state of
36: * that instance. If a joined inheritance strategy is used, or if
37: * the entity is otherwise mapped to a secondary table, this
38: * entails locking the row(s) for the entity instance in the
39: * additional table(s). Entity relationships for which the locked
40: * entity contains the foreign key will also be locked, but not
41: * the state of the referenced entities (unless those entities are
42: * explicitly locked). Element collections and relationships for
43: * which the entity does not contain the foreign key (such as
44: * relationships that are mapped to join tables or unidirectional
45: * one-to-many relationships for which the target entity contains
46: * the foreign key) will not be locked by default.
47: */
48: NORMAL,
49:
50: /**
51: * In addition to the locking behavior specified for {@link #NORMAL},
52: * element collections and relationships owned by the entity that
53: * are contained in join tables are locked if the property
54: * {@code jakarta.persistence.lock.scope} is specified with a value
55: * of {@code PessimisticLockScope#EXTENDED}. The state of entities
56: * referenced by such relationships is not locked (unless those
57: * entities are explicitly locked). Locking such a relationship or
58: * element collection generally locks only the rows in the join table
59: * or collection table for that relationship or collection. This means
60: * that phantoms are possible.
61: */
62: EXTENDED
63: }