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.Repeatable; 013import java.lang.annotation.Retention; 014import java.lang.annotation.Target; 015 016import static java.lang.annotation.ElementType.TYPE; 017import static java.lang.annotation.RetentionPolicy.RUNTIME; 018 019/** 020 * The NamedEntityGraph annotation is used to define a named entity graph. The entity graph may be retrieved 021 * by name using the EntityManagerFactory interface. The entity graph may be used to specify the path and 022 * boundaries for find operations or queries. The NamedEntityGraph annotation must be applied to the entity 023 * class that forms the root of the corresponding graph of entities. 024 * 025 * @since JPA 2.1 026 */ 027@Target({TYPE}) 028@Retention(RUNTIME) 029@Repeatable(NamedEntityGraphs.class) 030public @interface NamedEntityGraph { 031 /** 032 * The name element is used to refer to the entity graph. It defaults to the entity name of the root 033 * entity to which the annotation is applied. Entity graph names must be unique within the persistence 034 * unit. 035 * 036 * @return The name 037 */ 038 String name() default ""; 039 040 /** 041 * The attributeNodes element lists attributes of the annotated entity class that are to be included in 042 * the entity graph. 043 * 044 * @return The nodes 045 */ 046 NamedAttributeNode[] attributeNodes() default {}; 047 048 /** 049 * The includeAllAttributes element specifies that all attributes of the annotated entity class are to be 050 * included in the entity graph. An attributeNode element may still be used in conjunction with this 051 * element to specify a subgraph for the attribute. 052 * 053 * @return Whether to include attrs 054 */ 055 boolean includeAllAttributes() default false; 056 057 /** 058 * The subgraphs element specifies a list of subgraphs, further specifying attributes that are managed 059 * types. These subgraphs are referenced by name from NamedAttributeNode definitions. 060 * 061 * @return the subgraphs 062 */ 063 NamedSubgraph[] subgraphs() default {}; 064 065 /** 066 * The subclassSubgraphs element specifies a list of subgraphs that add additional attributes for 067 * subclasses of the root entity to which the annotation is applied. 068 * 069 * @return The subclass graphs 070 */ 071 NamedSubgraph[] subclassSubgraphs() default {}; 072}