Hi, I use variables (business objects) in ActionHandler
public class Task_ABC implements ActionHandler{
public void execute(ExecutionContext executionContext) throws Exception {
ContextInstance c = executionContext.getProcessInstance().getContextInstance();
Abc abc= (Abc) c.getVariable("abc");
.... do something ...
executionContext.leaveNode();
}
}
Problem is that this variables are not registered in session, if variable has an association and I use it, I get an exception. But if I have variable class has only primitive attributes (String, BigDecimal..) it works perfectly. Workaround is to declare all association in Hibernate as lazy="false" what I don't want. But really interesting is, that if I change value in variable that it will be stored in db. That means that jbpm will register variables in Hibernate session but later and I don't know when.
I don't use any special workflow configuration. This is snip set from my workflow interface:
public class WorkflowService extends HibernateDaoSupport implements IWorkflowService {
private static JbpmConfiguration jbpmConfiguration = JbpmConfiguration.getInstance();
public void startWorkflow(Workflow workflow, Map<String, Object> variables) {
JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
jbpmContext.setSessionFactory(getSessionFactory());
jbpmContext.setSession(getSession());
try {
ProcessInstance processInstance = jbpmContext.newProcessInstanceForUpdate(workflow.getFullName());
processInstance.getContextInstance().setTransientVariables(variables);
processInstance.signal();
} finally {
jbpmContext.close();
}
}
Thanks
Fero
Solved. My problem was that incoming variables form client were detached from session. So I attached them with saveOrUpdate method. When I read a process variable in ActionHandler it is always registered. So there was no problem.
Thanks