My Spring application leaks database connections whereas I use the default Roo configuration

非 Y 不嫁゛ 提交于 2019-12-04 18:49:42

I'm not sure if you are using hibernate? If so take a look at the setting hibernate.connection.release_mode . We had this issue and putting it to after_transaction solved all our connection issues.

EDIT

Our config:

<beans:bean id="entityManagerFactory"
    class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
        <beans:property name="dataSource" ref="mvcDatasource" />
        <beans:property name="persistenceUnitName" value="mvcPersistenceUnit" />

        <beans:property name="persistenceProvider">
            <beans:bean class="org.hibernate.ejb.HibernatePersistence" />
        </beans:property>

        <!-- Fix Hibernate not properly connected with spring -->
        <beans:property name="jpaVendorAdapter">
            <beans:bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter" />
        </beans:property>
        <beans:property name="jpaPropertyMap">
            <beans:map>
                <!-- Connection release fix -->
                <beans:entry key="hibernate.connection.release_mode" value="after_transaction" />

                <beans:entry key="hibernate.dialect" value="${hibernate.dialect}" />
    ...
        </beans:map>
    </beans:property>
</beans:bean>

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!