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
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.