Uploaded image for project: 'jBPM'
  1. jBPM
  2. JBPM-478

Timers don't save when using ClassicQueryTranslatorFactory

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Major
    • Resolution: Out of Date
    • Affects Version/s: jBPM 3.0.2
    • Fix Version/s: None
    • Component/s: Runtime Engine
    • Labels:
      None

      Description

      Unfortunately when using hibernate 3 with weblogic you have to use hibernate.query.factory_class=org.hibernate.hql.classic.ClassicQueryTranslatorFactory to configure hibernate because of antlr incompatibility between weblogic and hibernate.
      That causes the delete timers queries in SchedulerSession to fail with the following exception:
      org.hibernate.QueryException: query must begin with SELECT or FROM: delete [delete from org.jbpm.scheduler.exe.Timer where name = :timerName and token = :token]

      I had to modify the source code to not use the batch DML for now only in two methods that delete the timers. I'm going to modify the other code like that if we have the same issues as we go.

      The following is the code I use:

      private static final String deleteTimersQuery =
      "from org.jbpm.scheduler.exe.Timer t " +
      "where t.name = :timerName" +
      " and t.token = :token";
      public void cancelTimers(SchedulerInstance.CancelledTimer cancelledTimer) {
      try {
      Query query = session.createQuery(deleteTimersQuery);
      query.setString("timerName", cancelledTimer.getTimerName());
      query.setEntity("token", cancelledTimer.getToken());
      List timers = query.list();
      for (Iterator ti = timers.iterator(); ti.hasNext()

      { Timer timer = (Timer) ti.next(); session.delete(timer); }
      } catch (Exception e) { log.error(e); jbpmSession.handleException(); throw new RuntimeException("couldn't delete timers '"+cancelledTimer.getTimerName()+"' on token '"+cancelledTimer.getToken().getId()+"' from the database", e); }
      }

      private static final String deleteTimersForProcessInstanceQuery =
      "from org.jbpm.scheduler.exe.Timer t " +
      "where t.processInstance = :processInstance";
      public void cancelTimersForProcessInstance(ProcessInstance processInstance) {
      try {
      Query query = session.createQuery(deleteTimersForProcessInstanceQuery);
      query.setEntity("processInstance", processInstance);
      List timers = query.list();
      for (Iterator ti = timers.iterator(); ti.hasNext() { Timer timer = (Timer) ti.next(); session.delete(timer); }


      } catch (Exception e)

      { log.error(e); jbpmSession.handleException(); throw new RuntimeException("couldn't delete timers for process instance '"+processInstance+"'", e); }

      }

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                tom.baeyens Tom Baeyens
                Reporter:
                tpabka Aleksandr Tarutin
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: