Top Description Methods
javax.persistence

public Interface EntityGraph<T>

Type Parameters
<T>
The type of the root entity.
Imports
javax.persistence.metamodel.Attribute, java.util.List

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.

Since
Java Persistence 2.1
See Also
AttributeNode, Subgraph, NamedEntityGraph

Method Summary

Modifier and TypeMethod and Description
public void
addAttributeNodes(String...
name of the attribute
attributeName
)

Add one or more attribute nodes to the entity graph.

public void
addAttributeNodes(Attribute<T, ?>...
attribute
attribute
)

Add one or more attribute nodes to the entity graph.

public <X> Subgraph<X>

Returns:

subgraph for the key attribute
addKeySubgraph
(Attribute<T, X>
attribute
attribute
)

Add a node to the graph that corresponds to a map key that is a managed type.

public <X> Subgraph<? extends X>

Returns:

subgraph for the key attribute
addKeySubgraph
(Attribute<T, X>
attribute
attribute
,
Class<? extends X>
entity subclass
type
)

Add a node to the graph that corresponds to a map key that is a managed type with inheritance.

public <X> Subgraph<X>

Returns:

subgraph for the key attribute
addKeySubgraph
(String
name of the attribute
attributeName
)

Add a node to the graph that corresponds to a map key that is a managed type.

public <X> Subgraph<X>

Returns:

subgraph for the key attribute
addKeySubgraph
(String
name of the attribute
attributeName
,
Class<X>
entity subclass
type
)

Add a node to the graph that corresponds to a map key that is a managed type with inheritance.

public <T> Subgraph<? extends T>

Returns:

subgraph for the subclass
addSubclassSubgraph
(Class<? extends T>
entity subclass
type
)

Add additional attributes to this entity graph that correspond to attributes of subclasses of this EntityGraph's entity type.

public <X> Subgraph<X>

Returns:

subgraph for the attribute
addSubgraph
(Attribute<T, X>
attribute
attribute
)

Add a node to the graph that corresponds to a managed type.

public <X> Subgraph<? extends X>

Returns:

subgraph for the attribute
addSubgraph
(Attribute<T, X>
attribute
attribute
,
Class<? extends X>
entity subclass
type
)

Add a node to the graph that corresponds to a managed type with inheritance.

public <X> Subgraph<X>

Returns:

subgraph for the attribute
addSubgraph
(String
name of the attribute
attributeName
)

Add a node to the graph that corresponds to a managed type.

public <X> Subgraph<X>

Returns:

subgraph for the attribute
addSubgraph
(String
name of the attribute
attributeName
,
Class<X>
entity subclass
type
)

Add a node to the graph that corresponds to a managed type with inheritance.

public List<AttributeNode<?>>

Returns:

attribute nodes for the annotated entity type or empty list if none have been defined
getAttributeNodes
()

Return the attribute nodes of this entity that are included in the entity graph.

public 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.

Method Detail

addAttributeNodesback to summary
public void addAttributeNodes(String... attributeName)

Add one or more attribute nodes to the entity graph.

Parameters
attributeName:String[]

name of the attribute

Exceptions
IllegalArgumentException:
if the attribute is not an attribute of this entity.
IllegalStateException:
if the EntityGraph has been statically defined
addAttributeNodesback to summary
public void addAttributeNodes(Attribute<T, ?>... attribute)

Add one or more attribute nodes to the entity graph.

Parameters
attribute:Attribute<T, ?>[]

attribute

Exceptions
IllegalStateException:
if the EntityGraph has been statically defined
addKeySubgraphback to summary
public <X> Subgraph<X> addKeySubgraph(Attribute<T, X> 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<T, X>

attribute

Returns:Subgraph<X>

subgraph for the key attribute

Exceptions
IllegalArgumentException:
if the attribute's target type is not an entity
IllegalStateException:
if this EntityGraph has been statically defined
addKeySubgraphback to summary
public <X> Subgraph<? extends X> addKeySubgraph(Attribute<T, X> attribute, Class<? extends 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
attribute:Attribute<T, X>

attribute

type:Class<? extends X>

entity subclass

Returns:Subgraph<? extends X>

subgraph for the key attribute

Exceptions
IllegalArgumentException:
if the attribute's target type is not an entity
IllegalStateException:
if this EntityGraph has been statically defined
addKeySubgraphback to summary
public <X> 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:String

name of the attribute

Returns:Subgraph<X>

subgraph for the key attribute

Exceptions
IllegalArgumentException:
  • if the attribute is not an attribute of this entity.
  • if the attribute's target type is not an entity
IllegalStateException:
if this EntityGraph has been statically defined
addKeySubgraphback to summary
public <X> 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 automatically include the specified attributes of superclass subgraphs

Parameters
attributeName:String

name of the attribute

type:Class<X>

entity subclass

Returns:Subgraph<X>

subgraph for the key attribute

Exceptions
IllegalArgumentException:
  • if the attribute is not an attribute of this entity.
  • if the attribute's target type is not a managed type
IllegalStateException:
if this EntityGraph has been statically defined
addSubclassSubgraphback to summary
public <T> Subgraph<? extends T> addSubclassSubgraph(Class<? extends T> type)

Add additional attributes to this entity graph that correspond to attributes of subclasses of this EntityGraph's entity type. Subclass subgraphs will automatically include the specified attributes of superclass subgraphs.

Parameters
type:Class<? extends T>

entity subclass

Returns:Subgraph<? extends T>

subgraph for the subclass

Exceptions
IllegalArgumentException:
if the type is not an entity type
IllegalStateException:
if the EntityGraph has been statically defined
addSubgraphback to summary
public <X> Subgraph<X> addSubgraph(Attribute<T, 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<T, X>

attribute

Returns:Subgraph<X>

subgraph for the attribute

Exceptions
IllegalArgumentException:
if the attribute's target type is not a managed type
IllegalStateException:
if the EntityGraph has been statically defined
addSubgraphback to summary
public <X> Subgraph<? extends X> addSubgraph(Attribute<T, X> attribute, Class<? extends 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
attribute:Attribute<T, X>

attribute

type:Class<? extends X>

entity subclass

Returns:Subgraph<? extends X>

subgraph for the attribute

Exceptions
IllegalArgumentException:
if the attribute's target type is not a managed type
IllegalStateException:
if the EntityGraph has been statically defined
addSubgraphback to summary
public <X> 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:String

name of the attribute

Returns:Subgraph<X>

subgraph for the attribute

Exceptions
IllegalArgumentException:
  • if the attribute is not an attribute of this entity.
  • if the attribute's target type is not a managed type
IllegalStateException:
if the EntityGraph has been statically defined
addSubgraphback to summary
public <X> 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:String

name of the attribute

type:Class<X>

entity subclass

Returns:Subgraph<X>

subgraph for the attribute

Exceptions
IllegalArgumentException:
  • if the attribute is not an attribute of this managed type.
  • if the attribute's target type is not a managed type
IllegalStateException:
if this EntityGraph has been statically defined
getAttributeNodesback to summary
public List<AttributeNode<?>> getAttributeNodes()

Return the attribute nodes of this entity that are included in the entity graph.

Returns:List<AttributeNode<?>>

attribute nodes for the annotated entity type or empty list if none have been defined

getNameback to summary
public 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.