cancel
Showing results for 
Search instead for 
Did you mean: 

Is it possible to create a local task variable on a completion event?

robojeff
Champ in-the-making
Champ in-the-making
I'd like to create a local task variable during the completion event for that task (User Task).  I've attempted to do this with a TaskListener:


public class RoutingOptionAuditor implements TaskListener {
    private Expression routeExpression;

    @Override
    public void notify(DelegateTask delegateTask) {
        String routingOption = getRoutingOption(delegateTask); // extracts the variable value to store; not shown here
        TaskService taskService = getTaskService(delegateTask);

        taskService.setVariableLocal(delegateTask.getId(), "routingOption", routingOption);
    }


When the last line executes, Activiti coughs up a nice SQL exception:


### Error updating database.  Cause: org.h2.jdbc.JdbcSQLException: Referential integrity constraint violation: "ACT_FK_VAR_EXE: PUBLIC.ACT_RU_VARIABLE FOREIGN KEY(EXECUTION_ID_) REFERENCES PUBLIC.ACT_RU_EXECUTION(ID_) ('5')"; SQL statement:
delete from ACT_RU_EXECUTION where ID_ = ? and REV_ = ? [23503-192]
### The error may involve org.activiti.engine.impl.persistence.entity.ExecutionEntity.deleteExecution-Inline
### The error occurred while setting parameters
### SQL: delete from ACT_RU_EXECUTION where ID_ = ? and REV_ = ?
### Cause: org.h2.jdbc.JdbcSQLException: Referential integrity constraint violation: "ACT_FK_VAR_EXE: PUBLIC.ACT_RU_VARIABLE FOREIGN KEY(EXECUTION_ID_) REFERENCES PUBLIC.ACT_RU_EXECUTION(ID_) ('5')"; SQL statement:
delete from ACT_RU_EXECUTION where ID_ = ? and REV_ = ? [23503-192]


I'm interpreting this error to mean that I've attempted to create a new local task variable while Activiti is in the middle of a transaction to delete the User Task.  Is that correct?
1 REPLY 1

gdharley
Elite Collaborator
Elite Collaborator

I believe the following thread answers this question.
 

Greg