1 Reply Latest reply on Oct 24, 2006 5:23 AM by Jean Guyer

    How to query process instances by process variables

    Marcel Marcel Newbie

      Olá,

      how can i query all process instances which contain
      a specific process variable like "givenName"="marcel"?
      (an entry in JBPM_VARIABLEINSTANCE).

      Is there a convenience method to do so or do i need to
      create my own queries in hibernate.queries.hbm.xml?

      And then access it with something like

      ---------------------------
      org.hibernate.Session session = jbpmContext.getSession();
      org.hibernate.Query query =
      session.getNamedQuery("MarcelsSpecial.findByVariable");
      query.setEntity("NAME_", "givenName");
      query.setEntity("STRINGVALUE_", "marcel");
      query.list();
      ---------------------------

      thanks for some enlightenment,

      Marcel

        • 1. Re: How to query process instances by process variables
          Jean Guyer Newbie

          I use something like that :

          Query query = this.procMgr.getSession().createQuery("select vi from org.jbpm.context.exe.VariableInstance vi where vi.name = :varname and vi.value=:varvalue");
           query.setString("varname", varName);
           query.setString("varvalue", varValue);
           List<VariableInstance> lstVarInstances = query.list();


          Of course , you need to make a join on ProcessIntance for your needs.
          You don't have to put it in hibernate.queries.hbm.xml unless you want to.