org.hibernate.graph.Graph Maven / Gradle / Ivy
Show all versions of beangle-hibernate-core Show documentation
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
*/
package org.hibernate.graph;
import java.util.List;
import org.hibernate.metamodel.model.domain.ManagedDomainType;
import org.hibernate.metamodel.model.domain.PersistentAttribute;
/**
* A container for {@link AttributeNode} references.
*
* Acts as a "bridge" between JPA's {@link jakarta.persistence.EntityGraph}
* and {@link jakarta.persistence.Subgraph}.
*
* @author Strong Liu
* @author Steve Ebersole
* @author Andrea Boriero
*/
@SuppressWarnings({"unused", "UnusedReturnValue"})
public interface Graph extends GraphNode {
/**
* Graphs apply only to {@link jakarta.persistence.metamodel.ManagedType}s.
*
* @return the {@code ManagedType} being graphed here.
*/
ManagedDomainType getGraphedType();
/**
* Create a named root {@link Graph} if the given name is not null.
*
* @param mutable controls whether the resulting {@code Graph} is mutable
*
* @throws CannotBecomeEntityGraphException If the named attribute is not entity-valued
*/
RootGraph makeRootGraph(String name, boolean mutable) throws CannotBecomeEntityGraphException;
/**
* Create a (mutable or immutable) {@link SubGraph} rooted at this {@link Graph}.
*/
SubGraph makeSubGraph(boolean mutable);
@Override
Graph makeCopy(boolean mutable);
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// AttributeNode handling
/**
* Ultimately only needed for implementing {@link jakarta.persistence.EntityGraph#getAttributeNodes()}
* and {@link jakarta.persistence.Subgraph#getAttributeNodes()}
*/
List> getGraphAttributeNodes();
/**
* Find an already existing AttributeNode by attributeName within this
* container
*/
AttributeNode findAttributeNode(String attributeName);
/**
* Find an already existing AttributeNode by corresponding attribute
* reference, within this container
*/
AttributeNode findAttributeNode(PersistentAttribute extends J, AJ> attribute);
/**
* Get a list of all existing AttributeNodes within this container
*/
List> getAttributeNodeList();
/**
* Add an AttributeNode (with no associated SubGraphNodes) to this container
* by attribute name
*/
AttributeNode addAttributeNode(String attributeName);
/**
* Add an AttributeNode (with no associated SubGraphNode) to this container
* by Attribute reference
*/
AttributeNode addAttributeNode(PersistentAttribute extends J,AJ> attribute);
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// sub graph nodes
/**
* Create a (mutable) SubGraphNode associated with the named AttributeNode.
* The created SubGraphNode is returned
*
* @apiNote If no such AttributeNode exists yet, it is created.
*/
SubGraph addSubGraph(String attributeName) throws CannotContainSubGraphException;
SubGraph addSubGraph(String attributeName, Class type) throws CannotContainSubGraphException;
/**
* Create a (mutable) SubGraphNode associated with the AttributeNode for the given
* Attribute. The created SubGraphNode is returned
*
* @apiNote If no such AttributeNode exists yet, it is created.
*/
SubGraph addSubGraph(PersistentAttribute extends J, AJ> attribute) throws CannotContainSubGraphException;
SubGraph extends AJ> addSubGraph(PersistentAttribute extends J, AJ> attribute, Class extends AJ> type) throws CannotContainSubGraphException;
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// key sub graph nodes
SubGraph addKeySubGraph(String attributeName) throws CannotContainSubGraphException;
SubGraph addKeySubGraph(String attributeName, Class type) throws CannotContainSubGraphException;
SubGraph addKeySubGraph(PersistentAttribute extends J,AJ> attribute) throws CannotContainSubGraphException;
SubGraph extends AJ> addKeySubGraph(PersistentAttribute extends J,AJ> attribute, Class extends AJ> type) throws CannotContainSubGraphException;
}