Hi,
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 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?
Thanks!
Thorben
Code:
@Entity
@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>();
Code:
@Entity
public class OrderItem implements Serializable
{
@ManyToOne(fetch = FetchType.LAZY)
private Product product;