cancel
Showing results for 
Search instead for 
Did you mean: 

Activiti-Process details are not saving in database

sudhakarkamat
Champ in-the-making
Champ in-the-making
Hello team,

I am working on running simple BPMN flow through actviti. I am able to execute script and service tasks.
But the process details are not getting saved to db .
Below are my files.
activiti.cfg-mem-fullhistory.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans   http://www.springframework.org/schema/beans/spring-beans.xsd">
       
 
<bean id="dataSource"
      class="org.springframework.jdbc.datasource.SimpleDriverDataSource">
      <property name="driverClass" value="org.h2.Driver" />
      <property name="url" value="jdbc:h2:mem:activiti;DB_CLOSE_DELAY=-1;MVCC=TRUE" />
      <property name="username" value="sa" />
      <property name="password" value="" />
   </bean>

   <bean id="transactionManager"
      class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
      <property name="dataSource" ref="dataSource" />
   </bean>

   <bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration"
      depends-on="dataSource,transactionManager">
      <property name="databaseType" value="h2" />
      <property name="dataSource" ref="dataSource" />
      <property name="transactionManager" ref="transactionManager" />
      <property name="databaseSchemaUpdate" value="true" />
      <!– property name="databaseSchemaUpdate" value="create-drop" /–>
      <property name="jobExecutorActivate" value="false" />
      <property name="history" value="none" />
      <property name="deploymentResources" value="classpath*:activiti/*.bpmn" />
   </bean>

</beans>

Test file.
public class LoanRequestTest  {   
   
  @Rule
   public ActivitiRule activitiRule = new ActivitiRule("activiti.cfg-mem-fullhistory.xml");

   @Test
   @Deployment(resources={"diagrams\\loanrequest_firstpart.bpmn20.xml"})
   public void creditCheckTrue() {
      Map<String, Object> processVariables = new HashMap<String, Object>();
      
      processVariables.put("creditCheckOk", true);
      processVariables.put("name", "Miss Piggy");
      processVariables.put("income", 100l);
      processVariables.put("loanAmount", 10l);
      processVariables.put("emailAddress", "miss.piggy@localhost");
      activitiRule.getRuntimeService().startProcessInstanceByKey(
              "loanrequest", processVariables);
      
      List<HistoricDetail> historyVariables = activitiRule.getHistoryService()//This object is coming null
          .createHistoricDetailQuery()
          .variableUpdates()
          .orderByVariableName()
          .asc()
          .list();
      
      assertNotNull(historyVariables);
      assertEquals(0, historyVariables.size());
      HistoricVariableUpdate loanAppUpdate = ((HistoricVariableUpdate) historyVariables.get(0));
      assertEquals("loanApplication", loanAppUpdate.getVariableName());
      LoanApplication la = (LoanApplication) loanAppUpdate.getValue();
      assertEquals(true, la.isCreditCheckOk());
   }
}

When the processes will be saved in database.
1 REPLY 1

yvoswillens
Champ in-the-making
Champ in-the-making
Hi,

try changing

<code>
@Deployment(resources={"diagrams\\loanrequest_firstpart.bpmn20.xml"})
</code>

in

<code>
@Deployment(resources = { "diagrams/loanrequest_firstpart.bpmn20.xml" })
</code>

Regards,

Yvo