I am having performance issues using hibernate. I have the following:
@Data
@Entity
@Table(name="\"Order_product\"")
public class OrderProduct {
@Id
@SequenceGenerator(name="Order_product_id_seq",
sequenceName="Order_product_id_seq",
allocationSize=1)
@GeneratedValue(strategy = GenerationType.SEQUENCE,
generator="Order_product_id_seq")
private long id;
@ManyToOne
@NotNull
private Product product;
@ManyToOne
@NotNull
private ProductPrice price;
@ManyToOne(fetch = FetchType.LAZY, optional = false)
@NotNull
private Order order;
}
Now, whenever I am trying to execute:
List<OrderProduct> findByOrderId(@Param(value = "order") Long orderId);
Hibernate will load whole Order for each OrderProduct. How can I disable this, so that only ID of the Order will load?