Hi all, I'm a bit confused as to how I select *only collection elements* (i.e. not their containing parent) via Criteria queries. Given this example from the documentation:
Code:
List results = session.createCriteria(Domestic.class, "cat")
.createAlias("kittens", "kit")
.setProjection( Projections.projectionList()
.add( Projections.property("cat.name"), "catName" )
.add( Projections.property("kit.name"), "kitName" )
)
.addOrder( Order.asc("catName") )
.addOrder( Order.asc("kitName") )
.list();
I want to change it so that I just select all of the kittens for some cat. I would think it would look like this:
Code:
List results = session.createCriteria(Domestic.class, "cat")
.createAlias("kittens", "kit")
.setProjection( Projections.projectionList()
.add( Projections.property("kit"))
)
.list();
But that doesn't appear to work. In hql I would do something like
Code:
select kittens from Cat as cat join cat.kittens as kittens
But I can't figure out the equivalent Criteria query. Any help would be greatly appreciated.