Hibernate criteria -- alias
- by Ignace
Hello,
I'm struggling a bit with the concept of alias in Hibernate.
My situation is the following:
Order
@OneToMany(cascade=CascadeType.ALL,mappedBy="m_order")
private Set<OrderDetail> m_details;
OrderDetail
@ManyToOne(cascade=CascadeType.ALL)
@JoinColumn(name="product_id")
private Product m_product;
@ManyToOne(cascade=CascadeType.ALL)
@JoinColumn(name="order_id")
private Order m_order;
DAO
c.createAlias("m_details", "detail").createCriteria("detail.m_product").add(Expression.idEq(productId));
So I want to search every order that contains a product.
However, with this query it keeps returning 0 orders and I don't really see what I'm doing wrong.
Thanks!