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
012import java.lang.annotation.Retention;
013import java.lang.annotation.Target;
014
015import static java.lang.annotation.ElementType.TYPE;
016import static java.lang.annotation.RetentionPolicy.RUNTIME;
017
018/**
019 * Specifies whether an entity should be cached if caching is enabled
020 * when the value of the <code>persistence.xml</code> caching element
021 * is <code>ENABLE_SELECTIVE</code> or <code>DISABLE_SELECTIVE</code>.
022 * The value of the <code>Cacheable</code> annotation is inherited by
023 * subclasses; it can be overridden by specifying
024 * <code>Cacheable</code> on a subclass.
025 * <p>
026 * <p> <code>Cacheable(false)</code> means that the entity and its state must
027 * not be cached by the provider.
028 *
029 * @since Java Persistence 2.0
030 */
031@Target({TYPE})
032@Retention(RUNTIME)
033public @interface Cacheable {
034
035  /**
036   * (Optional) Whether or not the entity should be cached.
037   */
038  boolean value() default true;
039}
040