Hi. I'm trying to understand how exactly OpenJPA does handle auto commit flag on connections. I've made sure that my connection pool always creates connections and has autoCommit set to false on them (it's Postgres, so by default, those come out with autoCommit=true). These are non-XA connections and/or pools. However, the pool doesn't force connections to be autoCommit=false (even though it's been asked to), when re-using previously established connection.
I also use JPA transaction manager. I needed to use Postgres large object manager, and that's when I found that the connections had autoCommit=true (LOM will not even produce an API if that's so). I changed my prologue code (executed for every thread that needs a DB connection) to be: em = emf.createEntityManager(); try { OpenJPAEntityManager oem = OpenJPAPersistence.cast(em); oem.getConnection().setAutoCommit(false); } catch (Exception e) { throw new RuntimeException(e); } EntityTransaction et = em.getTransaction(); if (!et.isActive()) { et.begin(); } This seems to have helped, by every now and then I still see exceptions related to autoCommit: <openjpa-2.2.1-r422266:1396819 fatal general error> org.apache.openjpa.persisten ce.PersistenceException: Cannot rollback when autoCommit is enabled. at org.apache.openjpa.jdbc.sql.DBDictionary.narrow(DBDictionary.java:495 8) at org.apache.openjpa.jdbc.sql.DBDictionary.newStoreException(DBDictiona ry.java:4918) at org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java :136) at org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java :110) at org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java :62) at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.rollback(JDBCStoreMan ager.java:219) at org.apache.openjpa.kernel.DelegatingStoreManager.rollback(DelegatingS toreManager.java:99) at org.apache.openjpa.kernel.BrokerImpl.endStoreManagerTransaction(Broke rImpl.java:1455) at org.apache.openjpa.kernel.BrokerImpl.endTransaction(BrokerImpl.java:2 353) at org.apache.openjpa.kernel.BrokerImpl.afterCompletion(BrokerImpl.java: 2012) at org.apache.openjpa.kernel.LocalManagedRuntime.rollback(LocalManagedRu ntime.java:124) at org.apache.openjpa.kernel.BrokerImpl.rollback(BrokerImpl.java:1538) at org.apache.openjpa.kernel.DelegatingBroker.rollback(DelegatingBroker. java:941) at org.apache.openjpa.persistence.EntityManagerImpl.rollback(EntityManag erImpl.java:599) I tried setting up break points on the connection's setAutoCommit() method, I didn't find anything much conclusive, but there was some code that had an _autoCommit flag, and attempted to restore the connection to this flag value, at least under certain circumstances.