KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > persistence > LockModeType


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23 package javax.persistence;
24
25 /**
26  * Lock modes that can be specified by means of the
27  * {@link EntityManager#lock EntityManager.lock()} method.
28  *
29  * <p> The semantics of requesting locks of type
30  * {@link LockModeType#READ LockModeType.READ} and {@link
31  * LockModeType#WRITE LockModeType.WRITE} are the following.
32  *
33  * <p> If transaction T1 calls lock(entity, {@link
34  * LockModeType#READ LockModeType.READ}) on a versioned object,
35  * the entity manager must ensure that neither of the following
36  * phenomena can occur:
37  * <ul>
38  * <li> P1 (Dirty read): Transaction T1 modifies a row.
39  * Another transaction T2 then reads that row and obtains
40  * the modified value, before T1 has committed or rolled back.
41  * Transaction T2 eventually commits successfully; it does not
42  * matter whether T1 commits or rolls back and whether it does
43  * so before or after T2 commits.
44  * <li>
45  * </li> P2 (Non-repeatable read): Transaction T1 reads a row.
46  * Another transaction T2 then modifies or deletes that row,
47  * before T1 has committed. Both transactions eventually commit
48  * successfully.
49  * </li>
50  * </ul>
51  *
52  * <p> Lock modes must always prevent the phenomena P1 and P2.
53  *
54  * <p> In addition, calling lock(entity, LockModeType.WRITE) on
55  * a versioned object, will also force an update (increment) to
56  * the entity's version column.
57  *
58  * <p> The persistence implementation is not required to support
59  * calling {@link EntityManager#lock EntityManager.lock()} on a
60  * non-versioned object. When it cannot support a such lock call,
61  * it must throw the {@link PersistenceException}.
62  *
63  *
64  * @since Java Persistence 1.0
65  */

66 public enum LockModeType {
67
68     /** Read lock */
69     READ,
70
71     /** Write lock */
72     WRITE
73 }
74
Popular Tags