Hibernate version:3
The javadocs for the Criteria API have
Code:
You may navigate associations using createAlias() or createCriteria()
...
List cats = session.createCriteria(Cat.class)
.createAlias("kittens", "kit")
.add( Restrictions.like("kit.name", "Iz%") )
.list();
I was wondering why Hibernate requires the user to create aliases for nested properties. Can't it internally create aliases for column properties if required? I'd like to be able to do the following
Code:
List cats = session.createCriteria(Cat.class)
.add( Restrictions.like("kittens.name", "Iz%") )
.list();
Same goes for addOrder:
Code:
crit.addOrder(Order.asc("kittens.name));
I'm constructing these Criteria's programatically for some generic sort/filter functionality and have access to the nested properties. Creating aliases seems like a redundant step. I'm sure is there for a resaon, just dont know what it is?
Thanks,
Sanjiv