AnsweredAssumed Answered

Cannot flush EntityManager, an active transaction is require

Question asked by javatech on Mar 27, 2012
Latest reply on May 14, 2016 by hung
Hi all,
activiti works fine if return type is void, if method returns "JPA Entity" 'LoanRequest'
is throws Cannot flush EntityManager, an active transaction is require.
@Transactional()
//public void createLoanRequest() { working fine

\\  below method throws "Cannot flush EntityManager, an active transaction is require" error
   public LoanRequest createLoanRequest() {

      System.out.println("Calling JPA Entity");
      LoanRequest loanRequest = new LoanRequest();
      loanRequest.setId(3424L);
      loanRequest.setValue("kiran");
      entityManager.persist(loanRequest);
       return loanRequest;
      
   }
xml looks like:
  <serviceTask  id="loanDeptReq" name="loanDeptReq"
    activiti:expression="${loanService.createLoanRequest()}" 
    activiti:resultVariable="loanRequest"/>


pls let me know if some missing in config or code.

Regards
Kiran.

Outcomes