Hibernate criteria -- alias
Posted
by Ignace
on Stack Overflow
See other posts from Stack Overflow
or by Ignace
Published on 2010-03-30T06:54:42Z
Indexed on
2010/03/30
7:43 UTC
Read the original article
Hit count: 393
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!
© Stack Overflow or respective owner