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 * Describes how a persistence context will be synchronized to the database in sync with JTA transactions 014 * 015 * @since Java Persistence 2.1 016 */ 017public enum SynchronizationType { 018 /** 019 * Indicates the persistence context is automatically enlisted in (joined to) the current JTA transaction. 020 */ 021 SYNCHRONIZED, 022 /** 023 * Indicates the persistence context is not enlisted in any JTA transaction unless explicitly joined to that 024 * transaction by invocation of the EntityManager {@link EntityManager#joinTransaction} method. The persistence 025 * context remains joined to the transaction until the transaction commits or rolls back. After the transaction 026 * commits or rolls back, the persistence context will not be joined to any subsequent transaction unless the 027 * joinTransaction method is invoked in the scope of that subsequent transaction. 028 * <p> 029 * Such a persistence context must not be flushed to the database unless it is joined to a transaction. The 030 * application's use of queries with pessimistic locks, bulk update or delete queries, etc. result in the 031 * provider throwing {@link TransactionRequiredException}. After the persistence context has been joined to the 032 * JTA transaction, these operations are again allowed. 033 */ 034 UNSYNCHRONIZED 035}