cancel
Showing results for 
Search instead for 
Did you mean: 

How to use the same Persistence Context of activiti ?

campa
Champ in-the-making
Champ in-the-making
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
1 REPLY 1

ronald_van_kuij
Champ on-the-rise
Champ on-the-rise
Activiti does not use a persistence context afaik (it is not JPA based), but if you use JTA, they should share the same transaction. You have to keep XA issues in mind though.