Вопрос

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.

Это было полезно?

Решение

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();
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top