Reputation: 45
I am opening transaction using TransactionInterceptor and using HibernateTransactionManager and com.zaxxer.hikari.HikariDataSource as datasource.
I have set autocommit value for datasource and hibernate property hibernate.connection.provider_disables_autocommit values as follows
<property name="autoCommit" value="false"/>
<prop key="hibernate.connection.provider_disables_autocommit">true</prop>
Even then the transaction is getting opened much before it is required.
5.3.1.Final version of hibernate-core is used for the above.
I have used the following references.
https://github.com/spring-projects/spring-boot/issues/9261
Please let me know in case anything else was required to be done or what is the exact meaning of delay.
Thanks in advance.
Upvotes: 3
Views: 6871
Reputation: 641
Apart from configuring autocommit as false in hibernate as you did, you also need to set autocommit to false at the connection pool level. Otherwise, it won't be effective as in your case. Say, for Hikari pool you need to configure as below:
HikariConfig hikariConfig = super.hikariConfig( dataSource );
hikariConfig.setAutoCommit( false );
Upvotes: 3