2 Replies Latest reply on Feb 6, 2014 3:48 AM by Thorben Janssen

    @NamedSubgraph not working?

    Thorben Janssen Newbie



      I am experimenting with the new entity graphs. I have 3 entities Order - OrderItem - Product and I want to define an entity graph for the Order that loads the OrderItem and Product (see below).

      The entity graph fetch.Order.items works for the OrderItem but not for the Product. Has anyone a working example for the usage of NamedSubgraph or can tell me what is wrong?






      @Table(name = "purchase_order")

      @NamedEntityGraph(name = "fetch.Order.items",

                          attributeNodes = @NamedAttributeNode(value = "items", subgraph = "items"),

                          subgraphs = @NamedSubgraph(name = "items", attributeNodes = @NamedAttributeNode("product")))

      public class Order implements Serializable {


          @OneToMany(mappedBy = "order", fetch = FetchType.LAZY)

          private Set<OrderItem> items = new HashSet<OrderItem>();




      public class OrderItem implements Serializable


         @ManyToOne(fetch = FetchType.LAZY)

         private Product product;