@Target(TYPE)
@Retention(RUNTIME)
@Repeatable(NamedEntityGraphs.class)
public @interface NamedEntityGraph
The NamedEntityGraph annotation is used to define a named entity graph. The entity graph may be retrieved
by name using the EntityManagerFactory interface. The entity graph may be used to specify the path and
boundaries for find operations or queries. The NamedEntityGraph annotation must be applied to the entity
class that forms the root of the corresponding graph of entities.
- Since:
- JPA 2.1
-
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionThe attributeNodes element lists attributes of the annotated entity class that are to be included in the entity graph.booleanThe includeAllAttributes element specifies that all attributes of the annotated entity class are to be included in the entity graph.The name element is used to refer to the entity graph.The subclassSubgraphs element specifies a list of subgraphs that add additional attributes for subclasses of the root entity to which the annotation is applied.The subgraphs element specifies a list of subgraphs, further specifying attributes that are managed types.
-
Element Details
-
name
String nameThe name element is used to refer to the entity graph. It defaults to the entity name of the root entity to which the annotation is applied. Entity graph names must be unique within the persistence unit.- Returns:
- The name
- Default:
- ""
-
attributeNodes
NamedAttributeNode[] attributeNodesThe attributeNodes element lists attributes of the annotated entity class that are to be included in the entity graph.- Returns:
- The nodes
- Default:
- {}
-
includeAllAttributes
boolean includeAllAttributesThe includeAllAttributes element specifies that all attributes of the annotated entity class are to be included in the entity graph. An attributeNode element may still be used in conjunction with this element to specify a subgraph for the attribute.- Returns:
- Whether to include attrs
- Default:
- false
-
subgraphs
NamedSubgraph[] subgraphsThe subgraphs element specifies a list of subgraphs, further specifying attributes that are managed types. These subgraphs are referenced by name from NamedAttributeNode definitions.- Returns:
- the subgraphs
- Default:
- {}
-
subclassSubgraphs
NamedSubgraph[] subclassSubgraphsThe subclassSubgraphs element specifies a list of subgraphs that add additional attributes for subclasses of the root entity to which the annotation is applied.- Returns:
- The subclass graphs
- Default:
- {}
-