Loading entity the below entity with {{OrderItem.withAll}}` fetch graph is ignored. Tested with a singular primary key. It is fine. It seems to fail only with a composite primary key. I attached an example maven project.
{code:java}@Entity @Table(name = "orderItem") @IdClass(OrderItem.PK.class) @NamedEntityGraph( name = "OrderItem.withAll", attributeNodes = { @NamedAttributeNode("product"), @NamedAttributeNode("order"), } ) public class OrderItem {
@Id @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "product_id") private Product product;
@Id @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "order_id") private Order order;
// getters, setters ommited
public static class PK implements Serializable { private Long product; private Long order;
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; PK pk = (PK) o; return Objects.equals(product, pk.product) && Objects.equals(order, pk.order); }
@Override public int hashCode() { return Objects.hash(product, order); } } }{code} |
|