-
1. Re: org.postgresql.util.PSQLException: Cannot commit when autoCommit is enabled.
ochaloup Feb 18, 2019 6:48 AM (in response to vata2999)Hi vata2999 ,
That's a kind of strange as it should not be that way. Do you use the
TransactionalDriverXAConnection?
for accessing the connection? In general you need the JDBC connection to be wrapped to managed the Narayana integration for you. Please consider reading our blogpost at https://jbossts.blogspot.com/2017/12/narayana-jdbc-transactional-driver.html and maybe rather see the quickstart about use of JDBC with standalone Narayana here https://github.com/jbosstm/quickstart/tree/master/transactionaldriver/transactionaldriver-standalone or you can consider Agroal integration (Narayana team blog: Narayana integration with Agroal connection pool).
-
2. Re: org.postgresql.util.PSQLException: Cannot commit when autoCommit is enabled.
tomjenkinson Feb 18, 2019 7:24 AM (in response to vata2999)It seems to me that you are likely not using an XA Connection. Please can you provide some details of you obtained the connection to PostGres? Is it using DBCP2 or using transactional driver? If you are using transactional driver then there is this quickstart: quickstart/README.md at master · jbosstm/quickstart · GitHub
-
3. Re: org.postgresql.util.PSQLException: Cannot commit when autoCommit is enabled.
vata2999 Feb 18, 2019 8:44 PM (in response to vata2999)to overcome this issue I added below settings to hibernate and changed NarayanaXADataSourceWrapper to ManagedDatasource
DataSourceXAConnectionFactory dataSourceXAConnectionFactory = new DataSourceXAConnectionFactory(tm, ds); PoolableConnectionFactory poolableConnectionFactory = new PoolableConnectionFactory(dataSourceXAConnectionFactory, null); poolableConnectionFactory.setDefaultAutoCommit(false); GenericObjectPool<PoolableConnection> connectionPool = new GenericObjectPool<>(poolableConnectionFactory); poolableConnectionFactory.setPool(connectionPool); return new ManagedDataSource<>(connectionPool, dataSourceXAConnectionFactory.getTransactionRegistry());
spring.jpa.properties.hibernate.connection.autocommit=false spring.jpa.properties.hibernate.connection.provider_disables_autocommit=true
-
4. Re: org.postgresql.util.PSQLException: Cannot commit when autoCommit is enabled.
tomjenkinson Feb 19, 2019 5:09 AM (in response to vata2999)Thanks for the update. I see we have some examples using ManagedDataSource too: Search · ManagedDatasource · GitHub