4 Replies Latest reply on Nov 22, 2008 6:06 PM by Ronald van Kuijk

    Error Saving ProcessInstance using AssignmentHandler

    John Hurt-Chan Newbie

      Hi,
      My code does a token.signal(). Then saves does a successful JbpmContext.save(ProcessInstance).

      But, when I add a AssignmentHandler for a Task in the Next Node, where I try to set the ActorID, I get a hibernate exception below...

      object references an unsaved transient instance - save the transient instance before flushing: org.jbpm.graph.exe.Token

      My code looks like this...

      public class AssignmentHandler extends BaseHandler implements AssignmentHandler
      {
       public void assign(Assignable assignable, ExecutionContext executionContext)
       {
       ContextInstance contextInstance = (ContextInstance)(executionContext.getProcessInstance()).getContextInstance();
       TaskInstance task = executionContext.getTaskInstance();
       task.setActorId(123);
       }
      }


      What do I need to do to fix it? I tried to modify that code above to try to save the TaskInstance that I modified the ActorID, but still get the same error...

      public class AssignmentHandler extends BaseHandler implements AssignmentHandler
      {
       public void assign(Assignable assignable, ExecutionContext executionContext)
       {
       ContextInstance contextInstance = (ContextInstance)(executionContext.getProcessInstance()).getContextInstance();
       TaskInstance task = executionContext.getTaskInstance();
       JbpmContext jbpmContext = Config.jbpmConfiguration.createJbpmContext();
       TaskInstance myTask = jbpmContext.getTaskInstanceForUpdate(task.getId());
       myTask.setActorId(user.getName());
       jbpmContext.save(myTask);
       jbpmContext.close();
       }
      }


      Help!