2 Replies Latest reply on Jul 21, 2006 3:22 PM by Michael Holtzman

    Hibernate query to get all active instances

    Michael Holtzman Newbie

      Greetings. As part of our application, I need to display all running process instances. I originally wrote some code to get all definitions (GraphSession.findAllProcessDefinitions()) and then, for each definition get the process instances (GraphSession.findProcessInstances(defnId)). It does what I need, but is very slow.

      I am trying to write a hib query to get the process instances in one db access. I'd like the results grouped by process definition name and version.

      String q = "from org.jbpm.graph.exe.ProcessInstance as pi" +
       " where pi.end is null" +
       " order by pi.processDefinition.name pi.processDefinition.version pi.start " ;
       Query qry = jbpmContext.getSession().createQuery(q);
       result = qry.list();
      


      This produces the following error:
      12:52:18,962 ERROR ErrorCounter : line 1:82: unexpected token: pi
      12:52:18,962 WARN HqlParser : processEqualityExpression() : No expression to process!
      12:52:18,962 ERROR Utility : unexpected token: pi near line 1, column 82 [from org.jbpm.graph.exe.ProcessInstance as pi
      order by pi.processDefinition.name pi.processDefinition.version pi.start ]
      


      Any suggestions? Thanx.