I'm using Hibernate in an application where I have 2 main requirements:
1. I need to make a query in hql, wich I store in metadata (xdoclet) giving it a name
2. I need to use this query by name AND filter it afterwards (let the final user apply additional filters to the original query results)
I would like to do something like:
Query q = getSession().getNamedQuery(queryName);
q.addCriteria(Expression.like(propertyName, propertyValue));
result = q.list();
I've tried filters, but they don't allow to filter query results, but persistent collections.
Is it possible to use the Criteria API against a query stored by name in HQL? In such case, how? If not, should I filter the query modifying the HQL string adding and clauses by hand? Is there any other aproach I'm missing?
Thanks in advance,
Jordi
|