Top Description Methods
org.hibernate.graph

public Interface Graph<J>

extends GraphNode<J>
Known Direct Subinterfaces
org.hibernate.graph.RootGraph, org.hibernate.graph.SubGraph, org.hibernate.graph.spi.GraphImplementor
Imports
java.util.List, jakarta.persistence.metamodel.PluralAttribute, org.hibernate.metamodel.model.domain.ManagedDomainType, .PersistentAttribute

A container for AttributeNode references.

API Note

Acts as an abstraction over the JPA-defined interfaces jakarta.persistence.EntityGraph and jakarta.persistence.Subgraph, which have no common supertype.

Authors
Strong Liu, Steve Ebersole, Andrea Boriero
See Also
RootGraph, SubGraph, jakarta.persistence.EntityGraph, jakarta.persistence.Subgraph

Method Summary

Modifier and TypeMethod and Description
public <AJ> AttributeNode<AJ>
addAttributeNode(String attributeName)

Add an AttributeNode (with no associated SubGraph) to this container by attribute name.

public <AJ> AttributeNode<AJ>
addAttributeNode(PersistentAttribute<? extends J, AJ> attribute)

Add an AttributeNode (with no associated SubGraph) to this container by attribute reference.

public <AJ> SubGraph<AJ>
addKeySubGraph(String attributeName)

public <AJ> SubGraph<AJ>
addKeySubGraph(String attributeName, Class<AJ> type)

public <AJ> SubGraph<AJ>
addKeySubGraph(PersistentAttribute<? extends J, AJ> attribute)

public <AJ> SubGraph<? extends AJ>
addKeySubGraph(PersistentAttribute<? extends J, AJ> attribute, Class<? extends AJ> type)

public default <AJ> SubGraph<AJ>
addPluralSubgraph(PluralAttribute<? extends J, ?, AJ> attribute)

Add a subgraph rooted at a plural attribute, allowing further nodes to be added to the subgraph.

public <AJ> SubGraph<AJ>
addSubGraph(String attributeName)

Create and return a new (mutable) SubGraph associated with the named AttributeNode.

public <AJ> SubGraph<AJ>
addSubGraph(String attributeName, Class<AJ> type)

public <AJ> SubGraph<AJ>
addSubGraph(PersistentAttribute<? extends J, AJ> attribute)

Create and return a new (mutable) SubGraph associated with the AttributeNode for the given attribute.

public <AJ> SubGraph<? extends AJ>
addSubGraph(PersistentAttribute<? extends J, AJ> attribute, Class<? extends AJ> type)

public <AJ> AttributeNode<AJ>
findAttributeNode(String attributeName)

Find an already existing AttributeNode by attributeName within this container

public <AJ> AttributeNode<AJ>
findAttributeNode(PersistentAttribute<? extends J, AJ> attribute)

Find an already existing AttributeNode by corresponding attribute reference, within this container.

public List<AttributeNode<?>>
getAttributeNodeList()

Get a list of all existing AttributeNodes within this container.

public List<AttributeNode<?>>
public ManagedDomainType<J>

Returns:

the ManagedType being graphed here.
getGraphedType
()

Graphs apply only to jakarta.persistence.metamodel.ManagedTypes.

public Graph<J>
public RootGraph<J>
makeRootGraph(String name, boolean
controls whether the resulting Graph is mutable
mutable
)

Create a named root Graph if the given name is not null.

public SubGraph<J>
makeSubGraph(boolean mutable)

Create a new (mutable or immutable) SubGraph rooted at this Graph.

Inherited from org.hibernate.graph.GraphNode:
isMutable

Method Detail

addAttributeNodeback to summary
public <AJ> AttributeNode<AJ> addAttributeNode(String attributeName)

Add an AttributeNode (with no associated SubGraph) to this container by attribute name.

addAttributeNodeback to summary
public <AJ> AttributeNode<AJ> addAttributeNode(PersistentAttribute<? extends J, AJ> attribute)

Add an AttributeNode (with no associated SubGraph) to this container by attribute reference.

addKeySubGraphback to summary
public <AJ> SubGraph<AJ> addKeySubGraph(String attributeName) throws CannotContainSubGraphException
addKeySubGraphback to summary
public <AJ> SubGraph<AJ> addKeySubGraph(String attributeName, Class<AJ> type) throws CannotContainSubGraphException
addKeySubGraphback to summary
public <AJ> SubGraph<AJ> addKeySubGraph(PersistentAttribute<? extends J, AJ> attribute) throws CannotContainSubGraphException
addKeySubGraphback to summary
public <AJ> SubGraph<? extends AJ> addKeySubGraph(PersistentAttribute<? extends J, AJ> attribute, Class<? extends AJ> type) throws CannotContainSubGraphException
addPluralSubgraphback to summary
public default <AJ> SubGraph<AJ> addPluralSubgraph(PluralAttribute<? extends J, ?, AJ> attribute)

Add a subgraph rooted at a plural attribute, allowing further nodes to be added to the subgraph.

API Note

This method is missing in JPA, and nodes cannot be added in a typesafe way to subgraphs representing fetched collections

Since
6.3
addSubGraphback to summary
public <AJ> SubGraph<AJ> addSubGraph(String attributeName) throws CannotContainSubGraphException

Create and return a new (mutable) SubGraph associated with the named AttributeNode.

API Note

If no such AttributeNode exists yet, it is created.

addSubGraphback to summary
public <AJ> SubGraph<AJ> addSubGraph(String attributeName, Class<AJ> type) throws CannotContainSubGraphException
addSubGraphback to summary
public <AJ> SubGraph<AJ> addSubGraph(PersistentAttribute<? extends J, AJ> attribute) throws CannotContainSubGraphException

Create and return a new (mutable) SubGraph associated with the AttributeNode for the given attribute.

API Note

If no such AttributeNode exists yet, it is created.

addSubGraphback to summary
public <AJ> SubGraph<? extends AJ> addSubGraph(PersistentAttribute<? extends J, AJ> attribute, Class<? extends AJ> type) throws CannotContainSubGraphException
findAttributeNodeback to summary
public <AJ> AttributeNode<AJ> findAttributeNode(String attributeName)

Find an already existing AttributeNode by attributeName within this container

findAttributeNodeback to summary
public <AJ> AttributeNode<AJ> findAttributeNode(PersistentAttribute<? extends J, AJ> attribute)

Find an already existing AttributeNode by corresponding attribute reference, within this container.

getAttributeNodeListback to summary
public List<AttributeNode<?>> getAttributeNodeList()

Get a list of all existing AttributeNodes within this container.

getGraphAttributeNodesback to summary
public List<AttributeNode<?>> getGraphAttributeNodes()

Ultimately only needed for implementing jakarta.persistence.EntityGraph#getAttributeNodes() and jakarta.persistence.Subgraph#getAttributeNodes()

getGraphedTypeback to summary
public ManagedDomainType<J> getGraphedType()

Graphs apply only to jakarta.persistence.metamodel.ManagedTypes.

Returns:ManagedDomainType<J>

the ManagedType being graphed here.

makeCopyback to summary
public Graph<J> makeCopy(boolean mutable)

Redeclares org.hibernate.graph.GraphNode.makeCopy.

Annotations
@Override
makeRootGraphback to summary
public RootGraph<J> makeRootGraph(String name, boolean mutable) throws CannotBecomeEntityGraphException

Create a named root Graph if the given name is not null.

Parameters
mutable:boolean

controls whether the resulting Graph is mutable

Exceptions
CannotBecomeEntityGraphException:
If the named attribute is not entity-valued
makeSubGraphback to summary
public SubGraph<J> makeSubGraph(boolean mutable)

Create a new (mutable or immutable) SubGraph rooted at this Graph.