Frage

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.

War es hilfreich?

Lösung

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();
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top