AnsweredAssumed Answered

transaction synchronization

Question asked by elsarfhem on Nov 18, 2011
Latest reply on Dec 5, 2011 by elsarfhem
Hi,
I'm not able to synchronize transtacion among jpa-spring-activity.
In my test case I tried to delete a process AND a JPA entity related to the process. The process was deleted also if the method throw an exception!
 
@Transactional
public void transactionalMethod(){
runtimeService.deleteProcessInstance(id, "");
entityDao.delete(daoInstance);         //<———- this will throw an exception
}

this is my spring-activiti db configuration

<!– ANNOTAZIONI –>
   <bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" />

   <!– DATASOURCE E JPA/HIBERNATE –>
   <jee:jndi-lookup id="dataSource" jndi-name="java:jdbc/cqds" />

   <bean id="entityManagerFactory"
      class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
      <property name="persistenceUnitName" value="ControlloQualitaPU" />
   </bean>

   <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
      <property name="entityManagerFactory" ref="entityManagerFactory" />
   </bean>

   <!– enable the configuration of transactional behavior based on annotations –>
   <tx:annotation-driven transaction-manager="transactionManager" />

   <!– Activiti –>
   <bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration">
      <property name="dataSource" ref="dataSource" />
      <property name="transactionManager" ref="transactionManager" />
      <property name="deploymentResources"
         value="classpath*:it/ipzs/iol/cq/process/autodeploy.*.bpmn20.xml" />
      <property name="databaseSchemaUpdate" value="true" />
      <property name="jobExecutorActivate" value="true" />
      <property name="history" value="full" />
      <!– JPA –>
      <property name="jpaEntityManagerFactory" ref="entityManagerFactory" />
      <property name="jpaHandleTransaction" value="true" />     <!– yet tested with false –>
      <property name="jpaCloseEntityManager" value="true" />   <!– yet tested with false –>
      
   </bean>

   <bean id="processEngine" class="org.activiti.spring.ProcessEngineFactoryBean">
      <property name="processEngineConfiguration" ref="processEngineConfiguration" />
   </bean>

   <bean id="repositoryService" factory-bean="processEngine"
      factory-method="getRepositoryService" />
   <bean id="runtimeService" factory-bean="processEngine"
      factory-method="getRuntimeService" />
   <bean id="taskService" factory-bean="processEngine"
      factory-method="getTaskService" />
   <bean id="historyService" factory-bean="processEngine"
      factory-method="getHistoryService" />
   <bean id="managementService" factory-bean="processEngine"
      factory-method="getManagementService" />
   <bean id="formService" factory-bean="processEngine"
      factory-method="getFormService" />

Do I have to use JTA? It depends from JNDI datasource (deployed through JBoss)?

Outcomes