Hi,
Is it possible to create an expression on attributes of an associated object by using just Expression and not createCriteria() for the association ?
I'd like to keep the layer in my application that constructs the expressions free from the Criteria stuffm and just pass in a collection of Expressions for the query. If I use createCriteria, I have to handle Hibernate exceptions, and have access to the Hibernate session, which I've abstracted out at the lower layer too.
Initially I thought that dot notation would work for associations, for example I could do the following (using a User object with an associated Address):
Code:
List criteriaList = new ArrayList();
Expression("name", "smith");
Expression("address.suburb", "Richmond");
queryWithCriteria(User.class, List)
where queryWithCriteria() constructs the actual Criteria using the list, and calls .list();
It seems that the dot notation works for components, but not for associtions, so I'd have to have access to the Criteria at the higher level, which kind of breaks my nice abstraction :-(
Any ideas ?
Cheers,
Darren.