I have a class which has two 1-many associations. My query should filter the result set on both associations. The Hibernate documentation just gives an example with a criteria on one associations:
Code:
List cats = sess.createCriteria(Cat.class)
.add( Expression.like("name", "F%")
.createCriteria("kittens")
.add( Expression.like("name", "F%")
How would I add an other criteria say to a 1-many association mates?
This does not work:
Code:
List cats = sess.createCriteria(Cat.class)
.add( Expression.like("name", "F%")
.createCriteria("kittens")
.add( Expression.like("name", "F%")
.createCriteria("mates")
.add( Expression.like("name", "T%")
Because Hibernate thinks that I want to add the criteria mates to the kittens.
Peter.