Question

How to enable MySQL auto commit in play 1.2.4?

I can find the auto commit in play 2.0 I tried using db.default.autocommit but in vain. Also through code i.e. setAutoCommit(true) but there was an exception while JPA tried to commit the transaction Please help.

Was it helpful?

Solution

PLay will commit automatically at the end of a transaction. If you need to commit within the transaction try something like this:

if (JPA.em().getTransaction().getRollbackOnly()) {
    JPA.em().getTransaction().rollback();
} else {
    JPA.em().getTransaction().commit();
}
JPA.em().getTransaction().begin();
JPA.em().flush();
JPA.em().clear();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top