Top Description Methods
jakarta.persistence

public Interface Graph<T>

Known Direct Subinterfaces
jakarta.persistence.Subgraph, jakarta.persistence.EntityGraph
Imports
jakarta.persistence.metamodel.Attribute, .MapAttribute, .PluralAttribute, java.util.List

Declares operations common to EntityGraph and Subgraph.
Since
3.2
See Also
EntityGraph, Subgraph

Method Summary

Modifier and TypeMethod and Description
public <Y> AttributeNode<Y>

Returns:

the attribute node
addAttributeNode
(String
name of the attribute
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.

public <Y> AttributeNode<Y>

Returns:

the attribute node
addAttributeNode
(Attribute<? super T, Y>
attribute
attribute
)

Get an existing attribute node for the given attribute, or add a new attribute node if there is no existing node.

public void
addAttributeNodes(String...
name of the attribute
attributeName
)

Add one or more attribute nodes to the entity graph.

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

Add one or more attribute nodes to the entity graph.

public <E> Subgraph<E>

Returns:

subgraph for the element attribute
addElementSubgraph
(PluralAttribute<? super T, ?, E>
attribute
attribute
)

Add a node to the graph that corresponds to a collection element that is a managed type.

public <X> Subgraph<X>

Returns:

subgraph for the element attribute
addElementSubgraph
(String
name of the attribute
attributeName
)

Add a node to the graph that corresponds to a collection element that is a managed type.

public <X> Subgraph<X>

Returns:

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

Add a node to the graph that corresponds to a collection element that is a managed type.

public <X> Subgraph<X>

Returns:

subgraph for the key attribute
addKeySubgraph
(Attribute<? super T, X>
attribute
attribute
)
Deprecated for removal since 3.2. use addMapKeySubgraph(MapAttribute)

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 attribute
addKeySubgraph
(Attribute<? super T, X>
attribute
attribute
,
Class<? extends X>
entity subclass
type
)
Deprecated for removal since 3.2. use addTreatedMapKeySubgraph(MapAttribute, Class)

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 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 <K> Subgraph<K>

Returns:

subgraph for the key attribute
addMapKeySubgraph
(MapAttribute<? super T, K, ?>
attribute
attribute
)

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 attribute
addSubgraph
(Attribute<? super 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<? super T, X>
attribute
attribute
,
Class<? extends X>
entity subclass
type
)
Deprecated for removal since 3.2. use addTreatedSubgraph(Attribute, Class)

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 <E> Subgraph<E>

Returns:

subgraph for the element attribute
addTreatedElementSubgraph
(PluralAttribute<? super T, ?, ? super E>
attribute
attribute
,
Class<E> type)

Add a node to the graph that corresponds to a collection element that is a managed type.

public <K> Subgraph<K>

Returns:

subgraph for the attribute
addTreatedMapKeySubgraph
(MapAttribute<? super T, ? super K, ?>
attribute
attribute
,
Class<K>
entity subclass
type
)

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

public <Y> Subgraph<Y>

Returns:

subgraph for the attribute
addTreatedSubgraph
(Attribute<? super T, ? super Y>
attribute
attribute
,
Class<Y>
entity subclass
type
)

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

public <Y> AttributeNode<Y>

Returns:

the attribute node
getAttributeNode
(String
name of the attribute
attributeName
)

Get an existing attribute node for the attribute with the given name.

public <Y> AttributeNode<Y>

Returns:

the attribute node
getAttributeNode
(Attribute<? super T, Y>
attribute
attribute
)

Get an existing attribute node for the given attribute.

public List<AttributeNode<?>>

Returns:

list of attribute nodes included in the graph or an empty list if none have been defined
getAttributeNodes
()

Return the attribute nodes corresponding to the attributes of this managed type that are included in the graph.

public boolean

Returns:

true if there is an existing attribute node
hasAttributeNode
(String
name of the attribute
attributeName
)

Determine if there is an existing attribute node for the attribute with the given name.

public boolean

Returns:

true if there is an existing attribute node
hasAttributeNode
(Attribute<? super T, ?>
attribute
attribute
)

Determine if there is an existing attribute node for the given attribute.

public void
removeAttributeNode(String
name of the attribute
attributeName
)

Remove an attribute node from the entity graph.

public void
removeAttributeNode(Attribute<? super T, ?>
attribute
attribute
)

Remove an attribute node from the entity graph.

public void
removeAttributeNodes(Attribute.PersistentAttributeType nodeTypes)

Remove all attribute nodes of the given attribute types.

Method Detail

addAttributeNodeback to summary
public <Y> 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:String

name of the attribute

Returns:AttributeNode<Y>

the attribute node

Exceptions
IllegalArgumentException:
if the attribute is not an attribute of this entity.
IllegalStateException:
if the EntityGraph has been statically defined
Since
3.2
addAttributeNodeback to summary
public <Y> AttributeNode<Y> addAttributeNode(Attribute<? super T, 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<? super T, Y>

attribute

Returns:AttributeNode<Y>

the attribute node

Exceptions
IllegalStateException:
if the EntityGraph has been statically defined
Since
3.2
addAttributeNodesback to summary
public 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:String[]

name of the attribute

Exceptions
IllegalArgumentException:
if the attribute is not an attribute of this managed type.
IllegalStateException:
if the EntityGraph has been statically defined
addAttributeNodesback to summary
public void addAttributeNodes(Attribute<? super T, ?>... 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<? super T, ?>[]

attribute

Exceptions
IllegalStateException:
if this EntityGraph has been statically defined
addElementSubgraphback to summary
public <E> Subgraph<E> addElementSubgraph(PluralAttribute<? super T, ?, 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:PluralAttribute<? super T, ?, E>

attribute

Returns:Subgraph<E>

subgraph for the element attribute

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

name of the attribute

Returns:Subgraph<X>

subgraph for the element 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
addElementSubgraphback to summary
public <X> 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:String

name of the attribute

type:Class<X>

entity subclass

Returns:Subgraph<X>

subgraph for the element 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
addKeySubgraphback to summary
public <X> Subgraph<X> addKeySubgraph(Attribute<? super T, X> attribute)

Deprecated

for removal since 3.2.

use addMapKeySubgraph(MapAttribute)

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<? super T, X>

attribute

Returns:Subgraph<X>

subgraph for the key attribute

Annotations
@Deprecated
since:3.2
forRemoval:true
Exceptions
IllegalArgumentException:
if the attribute's target type is not a managed type entity
IllegalStateException:
if this EntityGraph has been statically defined
addKeySubgraphback to summary
public <X> Subgraph<? extends X> addKeySubgraph(Attribute<? super T, X> attribute, Class<? extends X> type)

Deprecated

for removal since 3.2.

use addTreatedMapKeySubgraph(MapAttribute, Class)

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<? super T, X>

attribute

type:Class<? extends X>

entity subclass

Returns:Subgraph<? extends X>

subgraph for the attribute

Annotations
@Deprecated
since:3.2
forRemoval:true
Exceptions
IllegalArgumentException:
if the attribute's target type is not a managed type 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 a managed type
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 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 entity.
  • if the attribute's target type is not a managed type
IllegalStateException:
if this EntityGraph has been statically defined
addMapKeySubgraphback to summary
public <K> Subgraph<K> addMapKeySubgraph(MapAttribute<? super T, 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:MapAttribute<? super T, K, ?>

attribute

Returns:Subgraph<K>

subgraph for the key attribute

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

Deprecated

for removal since 3.2.

use addTreatedSubgraph(Attribute, Class)

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<? super T, X>

attribute

type:Class<? extends X>

entity subclass

Returns:Subgraph<? extends X>

subgraph for the attribute

Annotations
@Deprecated
since:3.2
forRemoval:true
Exceptions
IllegalArgumentException:
if the attribute's target type is not a managed type
IllegalStateException:
if this 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 managed type.
  • if the attribute's target type is not a managed type
IllegalStateException:
if this 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
addTreatedElementSubgraphback to summary
public <E> Subgraph<E> addTreatedElementSubgraph(PluralAttribute<? super T, ?, ? super E> 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:PluralAttribute<? super T, ?, ? super E>

attribute

Returns:Subgraph<E>

subgraph for the element attribute

Exceptions
IllegalArgumentException:
if the attribute's target type is not an entity
IllegalStateException:
if this EntityGraph has been statically defined
Since
3.2
addTreatedMapKeySubgraphback to summary
public <K> Subgraph<K> addTreatedMapKeySubgraph(MapAttribute<? super T, ? super K, ?> 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:MapAttribute<? super T, ? super K, ?>

attribute

type:Class<K>

entity subclass

Returns:Subgraph<K>

subgraph for the attribute

Exceptions
IllegalArgumentException:
if the attribute's target type is not a managed type entity
IllegalStateException:
if this EntityGraph has been statically defined
addTreatedSubgraphback to summary
public <Y> Subgraph<Y> addTreatedSubgraph(Attribute<? super T, ? super Y> 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<? super T, ? super Y>

attribute

type:Class<Y>

entity subclass

Returns:Subgraph<Y>

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
Since
3.2
getAttributeNodeback to summary
public <Y> AttributeNode<Y> getAttributeNode(String attributeName)

Get an existing attribute node for the attribute with the given name.

Parameters
attributeName:String

name of the attribute

Returns:AttributeNode<Y>

the attribute node

Exceptions
IllegalArgumentException:
if the attribute is not an attribute of this entity.
NoSuchElementException:
if there is no existing node for the attribute
Since
3.2
getAttributeNodeback to summary
public <Y> AttributeNode<Y> getAttributeNode(Attribute<? super T, Y> attribute)

Get an existing attribute node for the given attribute.

Parameters
attribute:Attribute<? super T, Y>

attribute

Returns:AttributeNode<Y>

the attribute node

Exceptions
NoSuchElementException:
if there is no existing node for the attribute
Since
3.2
getAttributeNodesback to summary
public List<AttributeNode<?>> getAttributeNodes()

Return the attribute nodes corresponding to the attributes of this managed type that are included in the graph.

Returns:List<AttributeNode<?>>

list of attribute nodes included in the graph or an empty list if none have been defined

hasAttributeNodeback to summary
public boolean hasAttributeNode(String attributeName)

Determine if there is an existing attribute node for the attribute with the given name.

Parameters
attributeName:String

name of the attribute

Returns:boolean

true if there is an existing attribute node

Exceptions
IllegalArgumentException:
if the attribute is not an attribute of this entity.
Since
3.2
hasAttributeNodeback to summary
public boolean hasAttributeNode(Attribute<? super T, ?> attribute)

Determine if there is an existing attribute node for the given attribute.

Parameters
attribute:Attribute<? super T, ?>

attribute

Returns:boolean

true if there is an existing attribute node

Since
3.2
removeAttributeNodeback to summary
public 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:String

name of the attribute

Since
3.2
removeAttributeNodeback to summary
public void removeAttributeNode(Attribute<? super T, ?> 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<? super T, ?>

attribute

Since
3.2
removeAttributeNodesback to summary
public void removeAttributeNodes(Attribute.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.

Since
3.2