My application builds a Criteria object progammatically. Filters (where ...) are created by one routine, while ordering (sort by ...) by another. It appears that Hibernate does not allow the same association to be referenced more than once. Here is some sample code that recreates the problem:
Code:
Criteria criteria = DB.session().createCriteria(Document.class);
criteria.createCriteria("client").add(Restrictions.eq("id", 1));
criteria.createCriteria("client").addOrder(Order.asc("name"));
List list = criteria.list();
It fails with "duplicate association path: client".
So... is there any way to work around it? For instance, is there any way to progammatically extract any Criteria objects that have possibly already been created for associations out of the root Criteria object?
Thank you in advance!