AnsweredAssumed Answered

How to use the same Persistence Context of activiti ?

Question asked by campa on Jul 5, 2011
Latest reply on Jul 5, 2011 by ronald.van.kuijk
Hi guys, I'd like to do some transactional JPA operations before, and also after, the starting, or the move on,  of activiti process instance.
Using the code below seems that the EntityManager injected by Spring is not the same instance/thread used by activti in the startProcessInstanceByKey execution.
I'm using activiti manual configuration for spring.

How can we have injected the same EntityManager used by activiti in his operations ?

   
@Autowired
private RuntimeService runtimeService;
@PersistenceContext
private EntityManager em;

@Ţransactional
public void invioAlLegale() {
      ….
      em.persist(myObject);
      em.remove(anotherObject);
      …      
      runtimeService.startProcessInstanceByKey(key, …);
                …

Thanks in advance
Stefano

Outcomes