Wednesday, August 17, 2016

Fix for "HibernateJpaDialect - JDBC Connection to reset not identical to originally prepared Connection" warning

After updating an application to Hibernate 5.1.1 from 5.1.0, I started seeing the following warning:

HibernateJpaDialect - JDBC Connection to reset not identical to originally prepared Connection

I did not find an "explicit" solution on the Internet, but looking through some of the code fixes in the ngrinder project, I figured out that I could fix my problem the same way by adding <prop key="hibernate.connection.release_mode">on_close</prop> to applicationContext.xml:

<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="persistenceUnitName" value="pu"/>
<property name="packagesToScan">
<list>
<value>com.appia.model.beans</value>
</list>
</property>
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="showSql" value="${orm.show_sql}"/>
<property name="databasePlatform" value="com.appia.pss.util.PostgresDialect"/>
</bean>
</property>
<property name="jpaProperties">
<props>
<prop key="hibernate.format_sql">${orm.format_sql}</prop>
<prop key="hibernate.connection.release_mode">on_close</prop>
</props>
</property>
</bean>

Thanks for this solution, JunHo!

No comments: