Class EntityGraphs


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

      • EntityGraphs

        public EntityGraphs()
    • Method Detail

      • merge

        public static <T> EntityGraph<T> merge​(EntityManager em,
                                               java.lang.Class<T> rootType,
                                               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.
      • merge

        @SafeVarargs
        public static <T> EntityGraph<T> merge​(Session session,
                                               java.lang.Class<T> rootType,
                                               Graph<T>... graphs)
      • executeList

        public static java.util.List executeList​(Query query,
                                                 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> java.util.List<R> executeList​(TypedQuery<R> query,
                                                        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
        ApiNote:
        This signature assumes that the Query's return is an entity and that the graph applies to that entity's type. JPA does not necessarily require that, but it is by far the most common usage.
      • executeList

        public static <R> java.util.List<R> executeList​(TypedQuery<R> query,
                                                        EntityGraph<R> graph,
                                                        java.lang.String semanticJpaHintName)
        Form of executeList(Query, EntityGraph, String) accepting a TypedQuery
        Parameters:
        query - The JPA Query
        graph - The graph to apply
        semanticJpaHintName - See GraphSemantic.fromJpaHintName(java.lang.String)
        ApiNote:
        This signature assumes that the Query's return is an entity and that the graph applies to that entity's type. JPA does not necessarily require that, but it is by far the most common usage.
      • executeList

        public static java.util.List executeList​(Query query,
                                                 EntityGraph graph)
        Convenience method for executing the Query using the given EntityGraph
        Parameters:
        query - The JPA Query
        graph - The graph to apply
        ApiNote:
        operates on the assumption that the "default" semantic for an entity graph applied to a Query is GraphSemantic.FETCH. This is simply knowledge from JPA EG discussions, nothing that is specifically mentioned or discussed in the spec.
      • executeList

        public static <R> java.util.List<R> executeList​(TypedQuery<R> query,
                                                        EntityGraph<R> graph)
        Form of executeList(Query, EntityGraph, String) accepting a TypedQuery
        Parameters:
        query - The JPA Query
        graph - The graph to apply
        ApiNote:
        This signature assumes that the Query's return is an entity and that the graph applies to that entity's type. JPA does not necessarily require that, but it is by far the most common usage.
      • areEqual

        public static <T> boolean areEqual​(EntityGraph<T> a,
                                           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​(AttributeNode<?> a,
                                       AttributeNode<?> b)
        Compares two entity graph attribute node and returns true if they are equal, ignoring subgraph attribute order.
      • areEqual

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

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