0 Replies Latest reply on Oct 27, 2010 11:24 AM by Michael Holtzman

    GraphSession.findLatestProcessDefinition() returns wrong value

    Michael Holtzman Newbie

      Greetings. We are having a problem deploying process instances. It seems that findLatestProcessDefinition() is returning null, even when there are clearly entries in JBPM_PROCESSDEFINITION with the same name.

       

      This is causing all sorts of problems:

           - Deploying a process definition keeps inserting multiple entries into JBPM_PROCESSDEFINITION with version = 1

           - Attempting to instantiate a definition fails (definition not found error) because no process definition object is returned for the name.

           - Etc.

       

      This happens sporadically across multiple schemas and platforms (Oracle and SqlServer). Typically some definitions will work OK and others will fail with this error.

       

      We are running jBPM 3.1.2 with some local mods. Thanx for any advice.

       

      Here is the underlying query:

       

       

      public ProcessDefinition findLatestProcessDefinition(String name) {
          ProcessDefinition processDefinition = null;
          try {
            Query query = session.getNamedQuery("GraphSession.findLatestProcessDefinitionQuery");
            query.setString("name", name);
            query.setMaxResults(1);
            processDefinition = (ProcessDefinition) query.uniqueResult();
          } catch (Exception e) {

       

             e.printStackTrace(); log.error(e);
            jbpmSession.handleException();
            throw new JbpmException("couldn't find process definition '" + name + "'", e);
          }
          return processDefinition;
        }

       

       

      <query name="GraphSession.findLatestProcessDefinitionQuery">
          <![CDATA[
           select pd
           from org.jbpm.graph.def.ProcessDefinition as pd
           where pd.name = :name
           order by pd.version desc   
          ]]>
        </query>