JPA Interface

EntityGraph

Type Parameters:
<T> - The type of the root entity.
Super Interfaces:
Graph<T>

This type represents the root of an entity graph that will be used as a template to define the attribute nodes and boundaries of a graph of entities and entity relationships. The root must be an entity type.

The methods to add subgraphs implicitly create the corresponding attribute nodes as well; such attribute nodes should not be redundantly specified.

See Also:
AttributeNode
Subgraph
NamedEntityGraph
createEntityGraph()
createEntityGraph()
getEntityGraph()
addNamedEntityGraph()
find()
Since:
JPA 2.1

Public Methods

AttributeNode<Y> addAttributeNode(Attribute<?superT,Y> attribute)
Get an existing attribute node for the given attribute, or add a new attribute node if there is no existing node.
Parameters:
attribute - attribute
Return:
the attribute node
Throws:
IllegalStateException - if the EntityGraph has been statically defined
Inherited from:
Graph<T>
Since:
JPA 3.2
AttributeNode<Y> addAttributeNode(String attributeName)
Get an existing attribute node for the attribute with the given name, or add a new attribute node if there is no existing node.
Parameters:
attributeName - name of the attribute
Return:
the attribute node
Throws:
IllegalArgumentException - if the attribute is not an attribute of this entity.
IllegalStateException - if the EntityGraph has been statically defined
Inherited from:
Graph<T>
Since:
JPA 3.2
void addAttributeNodes(Attribute<?superT,?>... attribute)
Add one or more attribute nodes to the entity graph.
If there is already an existing node for one of the given attributes, that particular argument is ignored and has no effect.
Parameters:
attribute - attribute
Throws:
IllegalStateException - if this EntityGraph has been statically defined
Inherited from:
Graph<T>
Since:
JPA 3.2
void addAttributeNodes(String... attributeName)
Add one or more attribute nodes to the entity graph.
If there is already an existing node for one of the given attribute names, that particular argument is ignored and has no effect.
Parameters:
attributeName - name of the attribute
Throws:
IllegalArgumentException - if the attribute is not an attribute of this managed type.
IllegalStateException - if the EntityGraph has been statically defined
Inherited from:
Graph<T>
Since:
JPA 3.2
Subgraph<E> addElementSubgraph(PluralAttribute<?superT,?,E> attribute)
Add a node to the graph that corresponds to a collection element that is a managed type.
This allows for construction of multi-node entity graphs that include related managed types.
Parameters:
attribute - attribute
Return:
subgraph for the element attribute
Throws:
IllegalArgumentException - if the attribute's target type is not an entity
IllegalStateException - if this EntityGraph has been statically defined
Inherited from:
Graph<T>
Since:
JPA 3.2
Subgraph<X> addElementSubgraph(String attributeName)
Add a node to the graph that corresponds to a collection element that is a managed type.
This allows for construction of multi-node entity graphs that include related managed types.
Parameters:
attributeName - name of the attribute
Return:
subgraph for the element attribute
Throws:
IllegalArgumentException - if the attribute is not an attribute of this entity.
IllegalArgumentException - if the attribute's target type is not a managed type
IllegalStateException - if this EntityGraph has been statically defined
Inherited from:
Graph<T>
Since:
JPA 3.2
Subgraph<X> addElementSubgraph(String attributeName, Class<X> type)
Add a node to the graph that corresponds to a collection element that is a managed type.
This allows for construction of multi-node entity graphs that include related managed types.
Parameters:
attributeName - name of the attribute
type - entity subclass
Return:
subgraph for the element attribute
Throws:
IllegalArgumentException - if the attribute is not an attribute of this entity.
IllegalArgumentException - if the attribute's target type is not a managed type
IllegalStateException - if this EntityGraph has been statically defined
Inherited from:
Graph<T>
Since:
JPA 3.2
Subgraph<X> addKeySubgraph(String attributeName)
Add a node to the graph that corresponds to a map key that is a managed type.
This allows for construction of multi-node entity graphs that include related managed types.
Parameters:
attributeName - name of the attribute
Return:
subgraph for the key attribute
Throws:
IllegalArgumentException - if the attribute is not an attribute of this entity.
IllegalArgumentException - if the attribute's target type is not a managed type
IllegalStateException - if this EntityGraph has been statically defined
Inherited from:
Graph<T>
Since:
JPA 3.2
Subgraph<X> addKeySubgraph(String attributeName, Class<X> type)
Add a node to the graph that corresponds to a map key that is a managed type with inheritance.
This allows for construction of multi-node entity graphs that include related managed types. Subclass subgraphs will include the specified attributes of superclass subgraphs
Parameters:
attributeName - name of the attribute
type - entity subclass
Return:
subgraph for the attribute
Throws:
IllegalArgumentException - if the attribute is not an attribute of this entity.
IllegalArgumentException - if the attribute's target type is not a managed type
IllegalStateException - if this EntityGraph has been statically defined
Inherited from:
Graph<T>
Since:
JPA 3.2
Subgraph<K> addMapKeySubgraph(MapAttribute<?superT,K,?> attribute)
Add a node to the graph that corresponds to a map key that is a managed type.
This allows for construction of multi-node entity graphs that include related managed types.
Parameters:
attribute - attribute
Return:
subgraph for the key attribute
Throws:
IllegalArgumentException - if the attribute's target type is not a managed type entity
IllegalStateException - if this EntityGraph has been statically defined
Inherited from:
Graph<T>
Since:
JPA 3.2
Subgraph<X> addSubgraph(Attribute<?superT,X> attribute)
Add a node to the graph that corresponds to a managed type.
This allows for construction of multi-node entity graphs that include related managed types.
Parameters:
attribute - attribute
Return:
subgraph for the attribute
Throws:
IllegalArgumentException - if the attribute's target type is not a managed type
IllegalStateException - if the EntityGraph has been statically defined
Inherited from:
Graph<T>
Since:
JPA 3.2
Subgraph<X> addSubgraph(String attributeName)
Add a node to the graph that corresponds to a managed type.
This allows for construction of multi-node entity graphs that include related managed types.
Parameters:
attributeName - name of the attribute
Return:
subgraph for the attribute
Throws:
IllegalArgumentException - if the attribute is not an attribute of this managed type.
IllegalArgumentException - if the attribute's target type is not a managed type
IllegalStateException - if this EntityGraph has been statically defined
Inherited from:
Graph<T>
Since:
JPA 3.2
Subgraph<X> addSubgraph(String attributeName, Class<X> type)
Add a node to the graph that corresponds to a managed type with inheritance.
This allows for multiple subclass subgraphs to be defined for this node of the entity graph. Subclass subgraphs will automatically include the specified attributes of superclass subgraphs
Parameters:
attributeName - name of the attribute
type - entity subclass
Return:
subgraph for the attribute
Throws:
IllegalArgumentException - if the attribute is not an attribute of this managed type.
IllegalArgumentException - if the attribute's target type is not a managed type
IllegalStateException - if this EntityGraph has been statically defined
Inherited from:
Graph<T>
Since:
JPA 3.2
Subgraph<E> addTreatedElementSubgraph(PluralAttribute<?superT,?,?superE> attribute, Class<E> type)
Add a node to the graph that corresponds to a collection element that is a managed type.
This allows for construction of multi-node entity graphs that include related managed types.
Parameters:
attribute - attribute
Return:
subgraph for the element attribute
Throws:
IllegalArgumentException - if the attribute's target type is not an entity
IllegalStateException - if this EntityGraph has been statically defined
Inherited from:
Graph<T>
Since:
JPA 3.2
Subgraph<K> addTreatedMapKeySubgraph(MapAttribute<?superT,?superK,?> attribute, Class<K> type)
Add a node to the graph that corresponds to a map key that is a managed type with inheritance.
This allows for construction of multi-node entity graphs that include related managed types. Subclass subgraphs will automatically include the specified attributes of superclass subgraphs
Parameters:
attribute - attribute
type - entity subclass
Return:
subgraph for the attribute
Throws:
IllegalArgumentException - if the attribute's target type is not a managed type entity
IllegalStateException - if this EntityGraph has been statically defined
Inherited from:
Graph<T>
Since:
JPA 3.2
Subgraph<Y> addTreatedSubgraph(Attribute<?superT,?superY> attribute, Class<Y> type)
Add a node to the graph that corresponds to a managed type with inheritance.
This allows for multiple subclass subgraphs to be defined for this node of the entity graph. Subclass subgraphs will automatically include the specified attributes of superclass subgraphs.
Parameters:
attribute - attribute
type - entity subclass
Return:
subgraph for the attribute
Throws:
IllegalArgumentException - if the attribute's target type is not a managed type
IllegalStateException - if the EntityGraph has been statically defined
Inherited from:
Graph<T>
Since:
JPA 3.2
Subgraph<S> addTreatedSubgraph(Class<S> type)
Add additional attributes to this entity graph that correspond to attributes of subclasses of the entity type of this EntityGraph.
Subclass subgraphs automatically include the specified attributes of superclass subgraphs.
Parameters:
type - entity subclass
Return:
subgraph for the subclass
Throws:
IllegalArgumentException - if the type is not an entity type
IllegalStateException - if the EntityGraph has been statically defined
Since:
JPA 2.1
AttributeNode<Y> getAttributeNode(Attribute<?superT,Y> attribute)
Get an existing attribute node for the given attribute.
Parameters:
attribute - attribute
Return:
the attribute node
Throws:
java.util.NoSuchElementException - if there is no existing node for the attribute
Inherited from:
Graph<T>
Since:
JPA 3.2
AttributeNode<Y> getAttributeNode(String attributeName)
Get an existing attribute node for the attribute with the given name.
Parameters:
attributeName - name of the attribute
Return:
the attribute node
Throws:
IllegalArgumentException - if the attribute is not an attribute of this entity.
java.util.NoSuchElementException - if there is no existing node for the attribute
Inherited from:
Graph<T>
Since:
JPA 3.2
Return the attribute nodes corresponding to the attributes of this managed type that are included in the graph.
Return:
list of attribute nodes included in the graph or an empty list if none have been defined
Inherited from:
Graph<T>
Since:
JPA 3.2
String getName()
Return the name of a named EntityGraph (an entity graph defined by means of the NamedEntityGraph annotation, XML descriptor element, or added by means of the addNamedEntityGraph() method).
Returns null if the EntityGraph is not a named EntityGraph.
Since:
JPA 2.1
boolean hasAttributeNode(Attribute<?superT,?> attribute)
Determine if there is an existing attribute node for the given attribute.
Parameters:
attribute - attribute
Return:
true if there is an existing attribute node
Inherited from:
Graph<T>
Since:
JPA 3.2
boolean hasAttributeNode(String attributeName)
Determine if there is an existing attribute node for the attribute with the given name.
Parameters:
attributeName - name of the attribute
Return:
true if there is an existing attribute node
Throws:
IllegalArgumentException - if the attribute is not an attribute of this entity.
Inherited from:
Graph<T>
Since:
JPA 3.2
void removeAttributeNode(Attribute<?superT,?> attribute)
Remove an attribute node from the entity graph.
When this graph is interpreted as a load graph, this operation suppresses inclusion of an attribute mapped for eager fetching. The effect of this call may be overridden by subsequent invocations of addAttributeNode() or addSubgraph(). If there is no existing node for the given attribute, this operation has no effect.
Parameters:
attribute - attribute
Inherited from:
Graph<T>
Since:
JPA 3.2
void removeAttributeNode(String attributeName)
Remove an attribute node from the entity graph.
When this graph is interpreted as a load graph, this operation suppresses inclusion of an attribute mapped for eager fetching. The effect of this call may be overridden by subsequent invocations of addAttributeNode() or addSubgraph(). If there is no existing node for the given attribute name, this operation has no effect.
Parameters:
attributeName - name of the attribute
Inherited from:
Graph<T>
Since:
JPA 3.2
void removeAttributeNodes(Attribute<X,Y>.PersistentAttributeType nodeTypes)
Remove all attribute nodes of the given attribute types.
When this graph is interpreted as a load graph, this operation suppresses inclusion of attributes mapped for eager fetching. The effect of this call may be overridden by subsequent invocations of addAttributeNode() or addSubgraph().
Inherited from:
Graph<T>
Since:
JPA 3.2