07-28-2012 06:47 AM
<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'.
@Override
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.
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 cachable08-02-2012 10:19 AM
08-02-2012 10:28 AM
08-04-2012 01:31 PM
Your approach seems valid, up to the point where you "flush" the entity-manager on each "set" of a variable. The entity-manager should only be flushed at the end of the command-context-chain (if all goes well).What is the command-context-chain? When i complete a user task, this starts a command-context-chain till execution arrives at the next wait state? Or from the start process to some wait state? Well, with the ensure-to-get-the-enities-id-flush this strategy already seems broken. From a performance perspective this might have an influence if many JPA entities are used as process variables and a flush is executed after each setValue. But if something goes bad a roll back is executed and the state of the process will still be valid, in terms of the execution and the data are synchronized?
So instead of getting the entity-manager directly in the setValue(), rather you should initialize the JPAEntityManagerSession the way the reading of JPA-variables does. This way, IF a variable is set, the entity manager is initialized in the session and will be not-null when session is flushed, resulting in the desired behavior.With JPAEntityManagerSession u mean the EntityManagerSessionImpl? if i got u right this is what i did when adding the em.merge… What about removing the entityManagerSession.flush() from the JPAEntityVariableType.setValue() call? This is only needed if JPA entities are created within Activiti tasks which dont have their identity set? In my case this would never be the case because the processes will always work on already existing entities. But as it has only a minor performance impact i think its not a big deal?
Could you try this approach and perhaps attach the patch, so we can introduce this in the acidity code-base?Well, that 4 lines of codes … if Activiti is designed the way that it does not touch JPA entities it might introduce side effects on other users which expect Activiti to not change their JPA entities? Maybe it is possible to introduce it with another jpaXXX config parameter for activiti.cfg.xml which defaults to the actual behavior?
08-05-2012 12:35 PM
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.