I want to retrieve a collection property using criteria
public class A {
private Collection<B> property
// getters and setters
}
public class B {
private int status
// getters and setters
}
My criteria code is as follows:
Criteria cr = getSession().createCriteria(A.class)
cr.createAlias("property", "prop")
cr.add(Restrictions.eq("prop.status", status));
cr.setProjection(Projections.property("prop"));
cr.list();
It's obvious this code doesn't work I wanted to simply demonstrate my intentions. I know how to achieve this using HQL, but I have to use Criteria API. Is what I am aiming for even possible using Criteria ?
Thanks, Peter