1 /*
2  * Copyright (c) 2008, 2019 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 javax.persistence;
18
19 /**
20  * Defines the values of the <code>javax.persistence.lock.scope</code>
21  * property for pessimistic locking.  This property may be passed as
22  * an argument to the methods of the {@link EntityManager},
23  * {@link Query}, and {@link TypedQuery} interfaces that
24  * allow lock modes to be specified or used with the
25  * {@link NamedQuery} annotation.
26  *
27  * @since 2.0
28  */

29 public enum PessimisticLockScope {
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 behavior for
52      * <code>PessimisticLockScope.NORMAL</code>, element collections
53      * and relationships owned by the entity that are contained in
54      * join tables will be locked if the
55      * <code>javax.persistence.lock.scope</code> property is specified
56      * with a value of <code>PessimisticLockScope.EXTENDED</code>.
57      * The state of entities referenced by such relationships will not
58      * be locked (unless those entities are explicitly locked).
59      * Locking such a relationship or element collection generally locks only
60      * the rows in the join table or collection table for that
61      * relationship or collection.  This means that phantoms will be
62      * possible.
63      */

64     EXTENDED
65 }
66