JPA eclipselink disables auto-commit

How to set autocommit false in JPA 2.0 and eclipselink 2.3.1. I am currently getting a jdbc connection from an eclipselink session and then setting auto commit false on a jdbc connection. Is there any other way to set autocommit false to jpa.

JpaEntityManager jpaEntityManager = JpaHelper.getEntityManager(em);
    AbstractSession session = (AbstractSession) jpaEntityManager.getActiveSession();
    UnitOfWork unitOfWork = (UnitOfWork) jpaEntityManager.getActiveSession();
    final Accessor accessor;
    if (session.isInTransaction() || session.isExclusiveIsolatedClientSession()) {
      accessor = session.getAccessor();
    } else {
      unitOfWork.beginEarlyTransaction();
      accessor = session.getAccessor();
      accessor.incrementCallCount(unitOfWork.getParent());
      accessor.decrementCallCount();
    }
    java.sql.Connection connection = accessor.getConnection();
    connection.setAutoCommit(false);
+4
source share

Source: https://habr.com/ru/post/1599453/


All Articles