Mule JPA persist is not inserting or updating

前端 未结 2 495
面向向阳花
面向向阳花 2021-01-25 04:38

I am using Mule JPA module for retrieving and insert/updating data. I can able retrieve data but not able to update the DB. Its giving no errors and as per the log it seems that

2条回答
  •  暖寄归人
    2021-01-25 05:01

    Finally could able to commit transaction using MULE JPA transport, by creating CustomTransactionFactory which starts the transaction.

    public class CustomTransactionFactory implements TransactionFactory{
    
    @Override
    public Transaction beginTransaction(MuleContext muleContext)
            throws TransactionException {
        EntityManagerFactory emf = muleContext.getRegistry().lookupObject("entityManagerFactory");
        TransactionFactory tf = new JPATransactionFactory();
    
        Transaction tx = tf.beginTransaction(muleContext);
        tx.bindResource(emf, emf.createEntityManager());
        tx.begin();
        return tx;
    }
    
    @Override
    public boolean isTransacted() {
        return true;
    }
    

    }

    By referring custom transaction manager in In-bound endpoint as below, we can achieve flow level transactions.

     
        
        
    

    Note: Transactional blocks are no more required.

提交回复
热议问题