AnsweredAssumed Answered

JPA process variables not fully supported?

Question asked by chris.joelly on Jul 28, 2012
Latest reply on Aug 5, 2012 by chris.joelly

i just figured out that JPA entities are defined as not cachable in JPAEntityVariableType.

I have the following use case where this is a real problem:

i use JSF/activiti-cdi, in the JSF based user task views i use things like:

<customer:detail customer="#{processVariables['order'].customer}" />
I observed that the entity 'customer', and its related entity 'address' is updated correctly when i modify values in the JSF view and execute

<h:commandButton id="complete" value="#{msg.completeTaskButton}" action="#{businessProcess.completeTask(true)}" />
Following the user task there are service tasks which works on the process variable 'order'.
But when i execute code like

   public void execute(DelegateExecution execution) throws Exception {
      Order order = (Order) execution.getVariable(VariableNames.ORDER);
i see that the values set on the entities just before in the user task are not there.
The reason is that in VariableInstanceEntity the following happens:

  public Object getValue() {
    if (!type.isCachable() || cachedValue==null) {
      cachedValue = type.getValue(this);
    return cachedValue;
In the 'order' referenced by cachedValue i see the modified entity from the user task, but due to the fact that JPAEntityVariableType is not cachable
it is read from the database and all modifications are lost.

Is this the expected behavior for JPA process variables?

If so, how can i solve this issue?