001/* 002 * Copyright (c) 2008, 2009, 2011 Oracle, Inc. All rights reserved. 003 * 004 * This program and the accompanying materials are made available under the 005 * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0 006 * which accompanies this distribution. The Eclipse Public License is available 007 * at http://www.eclipse.org/legal/epl-v10.html and the Eclipse Distribution License 008 * is available at http://www.eclipse.org/org/documents/edl-v10.php. 009 */ 010package javax.persistence; 011 012/** 013 * Defines the values of the <code>javax.persistence.lock.scope</code> property for pessimistic locking. This 014 * property may be passed as an argument to the methods of the {@link EntityManager}, {@link Query}, and 015 * {@link TypedQuery} interfaces that allow lock modes to be specified or used with the {@link NamedQuery} 016 * annotation. 017 * 018 * @since Java Persistence 2.0 019 */ 020public enum PessimisticLockScope { 021 /** 022 * This value defines the default behavior for pessimistic locking. 023 * <p> 024 * The persistence provider must lock the database row(s) that correspond to the non-collection-valued 025 * persistent state of that instance. If a joined inheritance strategy is used, or if the entity is 026 * otherwise mapped to a secondary table, this entails locking the row(s) for the entity instance in the 027 * additional table(s). Entity relationships for which the locked entity contains the foreign key will 028 * also be locked, but not the state of the referenced entities (unless those entities are explicitly 029 * locked). Element collections and relationships for which the entity does not contain the foreign key 030 * (such as relationships that are mapped to join tables or unidirectional one-to-many relationships for 031 * which the target entity contains the foreign key) will not be locked by default. 032 */ 033 NORMAL, 034 035 /** 036 * In addition to the behavior for <code>PessimisticLockScope.NORMAL</code>, element collections and 037 * relationships owned by the entity that are contained in join tables will be locked if the 038 * <code>javax.persistence.lock.scope</code> property is specified with a value of 039 * <code>PessimisticLockScope.EXTENDED</code>. The state of entities referenced by such relationships will 040 * not be locked (unless those entities are explicitly locked). Locking such a relationship or element 041 * collection generally locks only the rows in the join table or collection table for that relationship or 042 * collection. This means that phantoms will be possible. 043 */ 044 EXTENDED 045}