-
- Type Parameters:
T
- The type of the root entity.
public interface EntityGraph<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.
- Since:
- Java Persistence 2.1
- See Also:
AttributeNode
,Subgraph
,NamedEntityGraph
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method and Description void
addAttributeNodes(Attribute<T,?>... attribute)
Add one or more attribute nodes to the entity graph.void
addAttributeNodes(String... attributeName)
Add one or more attribute nodes to the entity graph.<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.<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.<X> Subgraph<X>
addKeySubgraph(String attributeName)
Add a node to the graph that corresponds to a map key that is a managed type.<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.<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.<X> Subgraph<X>
addSubgraph(Attribute<T,X> attribute)
Add a node to the graph that corresponds to a managed type.<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.<X> Subgraph<X>
addSubgraph(String attributeName)
Add a node to the graph that corresponds to a managed type.<X> Subgraph<X>
addSubgraph(String attributeName, Class<X> type)
Add a node to the graph that corresponds to a managed type with inheritance.List<AttributeNode<?>>
getAttributeNodes()
Return the attribute nodes of this entity that are included in the entity graph.String
getName()
Return the name of a named EntityGraph (an entity graph defined by means of theNamedEntityGraph
annotation, XML descriptor element, or added by means of theaddNamedEntityGraph
method.
-
-
-
Method Detail
-
getName
String getName()
Return the name of a named EntityGraph (an entity graph defined by means of theNamedEntityGraph
annotation, XML descriptor element, or added by means of theaddNamedEntityGraph
method. Returns null if the EntityGraph is not a named EntityGraph.
-
addAttributeNodes
void addAttributeNodes(String... attributeName)
Add one or more attribute nodes to the entity graph.- Parameters:
attributeName
- name of the attribute- Throws:
IllegalArgumentException
- if the attribute is not an attribute of this entity.IllegalStateException
- if the EntityGraph has been statically defined
-
addAttributeNodes
void addAttributeNodes(Attribute<T,?>... attribute)
Add one or more attribute nodes to the entity graph.- Parameters:
attribute
- attribute- Throws:
IllegalStateException
- if the EntityGraph has been statically defined
-
addSubgraph
<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- Returns:
- subgraph for the attribute
- Throws:
IllegalArgumentException
- if the attribute's target type is not a managed typeIllegalStateException
- if the EntityGraph has been statically defined
-
addSubgraph
<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
- attributetype
- entity subclass- Returns:
- subgraph for the attribute
- Throws:
IllegalArgumentException
- if the attribute's target type is not a managed typeIllegalStateException
- if the EntityGraph has been statically defined
-
addSubgraph
<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
- name of the attribute- Returns:
- 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 typeIllegalStateException
- if the EntityGraph has been statically defined
-
addSubgraph
<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
- name of the attributetype
- entity subclass- Returns:
- 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 typeIllegalStateException
- if this EntityGraph has been statically defined
-
addKeySubgraph
<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- Returns:
- subgraph for the key attribute
- Throws:
IllegalArgumentException
- if the attribute's target type is not an entityIllegalStateException
- if this EntityGraph has been statically defined
-
addKeySubgraph
<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
- attributetype
- entity subclass- Returns:
- subgraph for the key attribute
- Throws:
IllegalArgumentException
- if the attribute's target type is not an entityIllegalStateException
- if this EntityGraph has been statically defined
-
addKeySubgraph
<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
- name of the attribute- Returns:
- 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 an entityIllegalStateException
- if this EntityGraph has been statically defined
-
addKeySubgraph
<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
- name of the attributetype
- entity subclass- Returns:
- 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 typeIllegalStateException
- if this EntityGraph has been statically defined
-
addSubclassSubgraph
<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
- entity subclass- Returns:
- subgraph for the subclass
- Throws:
IllegalArgumentException
- if the type is not an entity typeIllegalStateException
- if the EntityGraph has been statically defined
-
getAttributeNodes
List<AttributeNode<?>> getAttributeNodes()
Return the attribute nodes of this entity that are included in the entity graph.- Returns:
- attribute nodes for the annotated entity type or empty list if none have been defined
-
-
Traduction non disponible
Les API Java ne sont pas encore traduites en français sur l'infobrol. Seule la version anglaise est disponible pour l'instant.
Version en cache
21/08/2025 18:30:21 Cette version de la page est en cache (à la date du 21/08/2025 18:30:21) afin d'accélérer le traitement.Vous pouvez activer le mode utilisateur dans le menu en haut pour afficher la version plus récente de la page.
Document créé le 11/06/2005, dernière modification le 18/08/2025
Source du document imprimé : https://www.gaudry.be/java-api-javaee-rf-javax/persistence/EntityGraph.html
L'infobrol est un site personnel dont le contenu n'engage que moi. Le texte est mis à disposition sous licence CreativeCommons(BY-NC-SA). Plus d'info sur les conditions d'utilisation et sur l'auteur.
Références
Ces références et liens indiquent des documents consultés lors de la rédaction de cette page, ou qui peuvent apporter un complément d'information, mais les auteurs de ces sources ne peuvent être tenus responsables du contenu de cette page.
L'auteur de ce site est seul responsable de la manière dont sont présentés ici les différents concepts, et des libertés qui sont prises avec les ouvrages de référence. N'oubliez pas que vous devez croiser les informations de sources multiples afin de diminuer les risques d'erreurs.