Class EntityGraphs


  • public final class EntityGraphs
    extends Object
    A collection of EntityGraph utilities. These methods really belong inside other classes that we cannot modify, hence here.
    • Constructor Summary

      Constructors 
      Constructor Description
      EntityGraphs()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static boolean areEqual​(jakarta.persistence.AttributeNode<?> a, jakarta.persistence.AttributeNode<?> b)
      Compares two entity graph attribute node and returns true if they are equal, ignoring subgraph attribute order.
      static <T> boolean areEqual​(jakarta.persistence.EntityGraph<T> a, jakarta.persistence.EntityGraph<T> b)
      Compares two entity graphs and returns true if they are equal, ignoring attribute order.
      static boolean areEqual​(jakarta.persistence.Subgraph a, jakarta.persistence.Subgraph b)
      Compares two entity subgraphs and returns true if they are equal, ignoring attribute order.
      static boolean areEqual​(Map<Class,​jakarta.persistence.Subgraph> a, Map<Class,​jakarta.persistence.Subgraph> b)
      Compares two entity subgraph maps and returns true if they are equal, ignoring order.
      static List executeList​(jakarta.persistence.Query query, jakarta.persistence.EntityGraph graph)
      Convenience method for executing the Query using the given EntityGraph
      static List executeList​(jakarta.persistence.Query query, jakarta.persistence.EntityGraph graph, String semanticJpaHintName)
      Convenience method for executing the Query, applying the given EntityGraph using the named semantic using JPA's "hint name" - see GraphSemantic.fromJpaHintName(java.lang.String)
      static List executeList​(jakarta.persistence.Query query, jakarta.persistence.EntityGraph graph, GraphSemantic semantic)
      Convenience method for executing the Query, applying the given EntityGraph using the specified semantic
      static <R> List<R> executeList​(jakarta.persistence.TypedQuery<R> query, jakarta.persistence.EntityGraph<R> graph)
      Form of executeList(Query, EntityGraph, String) accepting a TypedQuery
      static <R> List<R> executeList​(jakarta.persistence.TypedQuery<R> query, jakarta.persistence.EntityGraph<R> graph, String semanticJpaHintName)
      Form of executeList(Query, EntityGraph, String) accepting a TypedQuery
      static <R> List<R> executeList​(jakarta.persistence.TypedQuery<R> query, jakarta.persistence.EntityGraph<R> graph, GraphSemantic semantic)
      Form of executeList(Query, EntityGraph, GraphSemantic) accepting a TypedQuery.
      static <T> jakarta.persistence.EntityGraph<T> merge​(jakarta.persistence.EntityManager em, Class<T> rootType, jakarta.persistence.EntityGraph<T>... graphs)
      Merges multiple entity graphs into a single graph that specifies the fetching/loading of all attributes the input graphs specify.
      static <T> jakarta.persistence.EntityGraph<T> merge​(SessionImplementor session, Class<T> rootType, GraphImplementor<T>... graphs)  
      static <T> jakarta.persistence.EntityGraph<T> merge​(Session session, Class<T> rootType, Graph<T>... graphs)  
    • Constructor Detail

      • EntityGraphs

        public EntityGraphs()
    • Method Detail

      • merge

        public static <T> jakarta.persistence.EntityGraph<T> merge​(jakarta.persistence.EntityManager em,
                                                                   Class<T> rootType,
                                                                   jakarta.persistence.EntityGraph<T>... graphs)
        Merges multiple entity graphs into a single graph that specifies the fetching/loading of all attributes the input graphs specify.
        Type Parameters:
        T - Root entity type of the query and graph.
        Parameters:
        em - EntityManager to use to create the new merged graph.
        rootType - Root type of the entity for which the graph is being merged.
        graphs - Graphs to merge.
        Returns:
        The merged graph.
      • executeList

        public static List executeList​(jakarta.persistence.Query query,
                                       jakarta.persistence.EntityGraph graph,
                                       GraphSemantic semantic)
        Convenience method for executing the Query, applying the given EntityGraph using the specified semantic
        Parameters:
        query - The JPA Query
        graph - The graph to apply
        semantic - The semantic to use when applying the graph
      • executeList

        public static <R> List<R> executeList​(jakarta.persistence.TypedQuery<R> query,
                                              jakarta.persistence.EntityGraph<R> graph,
                                              GraphSemantic semantic)
        Form of executeList(Query, EntityGraph, GraphSemantic) accepting a TypedQuery.
        Parameters:
        query - The JPA Query
        graph - The graph to apply
        semantic - The semantic to use when applying the graph
      • executeList

        public static List executeList​(jakarta.persistence.Query query,
                                       jakarta.persistence.EntityGraph graph)
        Convenience method for executing the Query using the given EntityGraph
        Parameters:
        query - The JPA Query
        graph - The graph to apply
      • executeList

        public static <R> List<R> executeList​(jakarta.persistence.TypedQuery<R> query,
                                              jakarta.persistence.EntityGraph<R> graph)
        Form of executeList(Query, EntityGraph, String) accepting a TypedQuery
        Parameters:
        query - The JPA Query
        graph - The graph to apply
      • areEqual

        public static <T> boolean areEqual​(jakarta.persistence.EntityGraph<T> a,
                                           jakarta.persistence.EntityGraph<T> b)
        Compares two entity graphs and returns true if they are equal, ignoring attribute order.
        Type Parameters:
        T - Root entity type of BOTH graphs.
        Parameters:
        a - Graph to compare.
        b - Graph to compare.
      • areEqual

        public static boolean areEqual​(jakarta.persistence.AttributeNode<?> a,
                                       jakarta.persistence.AttributeNode<?> b)
        Compares two entity graph attribute node and returns true if they are equal, ignoring subgraph attribute order.
      • areEqual

        public static boolean areEqual​(Map<Class,​jakarta.persistence.Subgraph> a,
                                       Map<Class,​jakarta.persistence.Subgraph> b)
        Compares two entity subgraph maps and returns true if they are equal, ignoring order.
      • areEqual

        public static boolean areEqual​(jakarta.persistence.Subgraph a,
                                       jakarta.persistence.Subgraph b)
        Compares two entity subgraphs and returns true if they are equal, ignoring attribute order.