@SuppressWarnings("unchecked")
public Collection<ProcessInstanceDAO> instanceQuery(String expression) {
Builder<String> builder = BuilderFactory.getInstance().createBuilder();
final org.apache.ode.ql.tree.nodes.Node rootNode = builder.build(expression);
HibernateInstancesQueryCompiler compiler = new HibernateInstancesQueryCompiler();
CommandEvaluator<List, Session> eval = compiler.compile((Query) rootNode);
List<HProcessInstance> instancesList = (List<HProcessInstance>) eval.evaluate(getSession());
Collection<ProcessInstanceDAO> result = new ArrayList<ProcessInstanceDAO>(instancesList.size());
for (HProcessInstance instance : instancesList) {
result.add(getInstance(instance.getId()));