AnsweredAssumed Answered

Create JPA entity in service task

Question asked by chris.joelly on Aug 19, 2011
Latest reply on Aug 31, 2011 by chris.joelly

is it possible to create an entity using JPA within an service task and store it as
process variable and use it in other service tasks? I have instantiated a @Entity
in an service task and stored it as process variable. The second service task
then is not able to retrieve that entity, nor is the entity persisted in the database:

Caused by: org.activiti.engine.ActivitiException: Entity does not exist: erp.model.test.TestErp - 801
   at org.activiti.engine.impl.variable.JPAEntityMappings.findEntity(
   at org.activiti.engine.impl.variable.JPAEntityMappings.getJPAEntity(
   at org.activiti.engine.impl.variable.JPAEntityVariableType.getValue(
   at org.activiti.engine.impl.persistence.entity.VariableInstanceEntity.getValue(
   at org.activiti.engine.impl.persistence.entity.VariableScopeImpl.getVariable(
   at erp.domain.activiti.tasks.service.SecondTask.execute(

and when i create the entity with an EJB which i lookup via JNDI in the service task then the
entity is created in the database and i can store it as process variable. But changes to that
process variable in service tasks are not synchronized to the database. The entity is only
available as process variable.

How can i get it synchronized so that the database and the EJB and the service tasks see the
same entity?