Package org.hibernate.graph
Class GraphParser
java.lang.Object
org.hibernate.graph.GraphParser
Parser for string representations of entity graphs.
The syntax is
graph:: (rootEntityName COLON)? attributeList attributeList:: attributeNode (COMMA attributeNode)* attributeNode:: attributePath subGraph? subGraph:: LPAREN (subTypeEntityName COLON)? attributeList RPARENThe
parse(java.lang.Class<T>, java.lang.CharSequence, org.hibernate.SessionFactory)
methods all create a root EntityGraph
based on the passed entity class and parse the graph string into that root graph.
The parseInto(org.hibernate.graph.Graph<T>, java.lang.CharSequence, jakarta.persistence.EntityManager)
methods parse the graph string into a passed graph, which may be a subgraph
Multiple graphs for the same entity type can be merged.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> RootGraph<T>
parse
(CharSequence graphText, SessionFactory sessionFactory) Creates a root graph based on the passedgraphText
.static <T> RootGraph<T>
parse
(Class<T> rootType, CharSequence graphText, EntityManager entityManager) Creates a root graph based on the passed `rootType` and parses `graphText` into the generated root graphstatic <T> RootGraph<T>
parse
(Class<T> rootEntityClass, CharSequence graphText, SessionFactory sessionFactory) Creates a root graph based on the passedrootEntityClass
and parsesgraphText
into the generated root graph.static <T> RootGraph<T>
parse
(String rootEntityName, CharSequence graphText, SessionFactory sessionFactory) Creates a root graph based on the passedrootEntityName
and parsesgraphText
into the generated root graph.static <T> void
parseInto
(EntityGraph<T> graph, CharSequence graphText, EntityManager entityManager) Parses the textual graph representation into the specified graph.static <T> void
parseInto
(EntityGraph<T> graph, CharSequence graphText, EntityManagerFactory entityManagerFactory) Parses the textual graph representation into the specified graph.static <T> void
parseInto
(Subgraph<T> graph, CharSequence graphText, EntityManager entityManager) Parses the textual graph representation into the specified graph.static <T> void
parseInto
(Subgraph<T> graph, CharSequence graphText, EntityManagerFactory entityManagerFactory) Parses the textual graph representation into the specified graph.static <T> void
parseInto
(Graph<T> graph, CharSequence graphText, EntityManager entityManager) Parses the textual graph representation into the specified graph.static <T> void
parseInto
(Graph<T> graph, CharSequence graphText, EntityManagerFactory entityManagerFactory) Parses the textual graph representation into the specified graph.
-
Constructor Details
-
GraphParser
public GraphParser()
-
-
Method Details
-
parse
public static <T> RootGraph<T> parse(Class<T> rootEntityClass, CharSequence graphText, SessionFactory sessionFactory) Creates a root graph based on the passedrootEntityClass
and parsesgraphText
into the generated root graph.- Parameters:
rootEntityClass
- The entity class to use as the graph rootgraphText
- The textual representation of the graphsessionFactory
- The SessionFactory- Throws:
InvalidGraphException
- if the textual representation is invalid.- Since:
- 7.0
- See Also:
- API Note:
- The string representation is expected to just be an attribute list, without
the entity-type prefix. E.g.
"title, isbn, author(name, books)"
-
parse
public static <T> RootGraph<T> parse(String rootEntityName, CharSequence graphText, SessionFactory sessionFactory) Creates a root graph based on the passedrootEntityName
and parsesgraphText
into the generated root graph.- Parameters:
rootEntityName
- The name of the entity to use as the graph rootgraphText
- The textual representation of the graphsessionFactory
- The SessionFactory- Throws:
InvalidGraphException
- if the textual representation is invalid.- Since:
- 7.0
- See Also:
- API Note:
- The string representation is expected to just be an attribute list, without
the entity-type prefix. E.g.
"title, isbn, author(name, books)"
-
parse
Creates a root graph based on the passedgraphText
. The format of this text is the root name with a colon, followed by an attribute list. E.g."Book: title, isbn, author(name, books)"
.- Parameters:
graphText
- The textual representation of the graphsessionFactory
- The SessionFactory- Throws:
InvalidGraphException
- if the textual representation is invalid.- Since:
- 7.0
- See Also:
-
parse
public static <T> RootGraph<T> parse(Class<T> rootType, CharSequence graphText, EntityManager entityManager) Creates a root graph based on the passed `rootType` and parses `graphText` into the generated root graph- Parameters:
rootType
- The root entity typegraphText
- The textual representation of the graphentityManager
- The EntityManager- Throws:
InvalidGraphException
- if the textual representation is invalid.- API Note:
- The passed EntityManager is expected to be a Hibernate implementation. Attempting to pass another provider's EntityManager implementation will fail.
- Implementation Note:
- Simply delegates to parse(Class, CharSequence, SessionFactory)
-
parseInto
public static <T> void parseInto(Graph<T> graph, CharSequence graphText, EntityManager entityManager) Parses the textual graph representation into the specified graph.- Parameters:
graph
- The target graph. This is the graph that will be populated by this processgraphText
- Textual representation of the graphentityManager
- The EntityManager- Throws:
InvalidGraphException
- if the textual representation is invalid.
-
parseInto
public static <T> void parseInto(EntityGraph<T> graph, CharSequence graphText, EntityManager entityManager) Parses the textual graph representation into the specified graph.- Parameters:
graph
- The target graph. This is the graph that will be populated by this processgraphText
- Textual representation of the graphentityManager
- The EntityManager- Throws:
InvalidGraphException
- if the textual representation is invalid.
-
parseInto
public static <T> void parseInto(Subgraph<T> graph, CharSequence graphText, EntityManager entityManager) Parses the textual graph representation into the specified graph.- Parameters:
graph
- The target graph. This is the graph that will be populated by this processgraphText
- Textual representation of the graphentityManager
- The EntityManager- Throws:
InvalidGraphException
- if the textual representation is invalid.
-
parseInto
public static <T> void parseInto(Graph<T> graph, CharSequence graphText, EntityManagerFactory entityManagerFactory) Parses the textual graph representation into the specified graph.- Parameters:
graph
- The target graph. This is the graph that will be populated by this processgraphText
- Textual representation of the graphentityManagerFactory
- The EntityManagerFactory- Throws:
InvalidGraphException
- if the textual representation is invalid.
-
parseInto
public static <T> void parseInto(EntityGraph<T> graph, CharSequence graphText, EntityManagerFactory entityManagerFactory) Parses the textual graph representation into the specified graph.- Parameters:
graph
- The target graph. This is the graph that will be populated by this processgraphText
- Textual representation of the graphentityManagerFactory
- The EntityManagerFactory- Throws:
InvalidGraphException
- if the textual representation is invalid.
-
parseInto
public static <T> void parseInto(Subgraph<T> graph, CharSequence graphText, EntityManagerFactory entityManagerFactory) Parses the textual graph representation into the specified graph.- Parameters:
graph
- The target graph. This is the graph that will be populated by this processgraphText
- Textual representation of the graphentityManagerFactory
- The EntityManagerFactory- Throws:
InvalidGraphException
- if the textual representation is invalid.
-