TestConnectionOnCheckin c3p0 Configuration Property in Hibernate/Spring Framework
I would like to set the testConnectionOnCheckin property for c3p0.
However I am having trouble doing so because the c3p0 datasource is created on my behalf within a hibernate entity-manager bean.
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="persistenceUnitManager" ref="persistenceUnitManager" />
<property name="persistenceProviderClass" value="org.hibernate.ejb.HibernatePersistence" />
<property name="jpaProperties">
<props>
<prop key="hibernate.dialect">${taxeng.entityManagerFactory.dialect}</prop>
<prop key="hibernate.hbm2ddl.auto">${taxeng.entityManagerFactory.ddl}</prop>
<prop key="hibernate.cache.provider_class">${taxeng.entityManagerFactory.cache}</prop>
<!-- Note that we use this due to the "ClassNotFoundException: org.hibernate.hql.ast.HqlToken" issue -->
<prop key="hibernate.query.factory_class">org.hibernate.hql.classic.ClassicQueryTranslatorFactory</prop>
<!-- Database connection pooling -->
<prop key="hibernate.c3p0.min_size">${taxeng.hibernate.c3p0.min_size}</prop>
<prop key="hibernate.c3p0.max_size">${taxeng.hibernate.c3p0.max_size}</prop>
<prop key="hibernate.c3p0.timeout">${taxeng.hibernate.c3p0.timeout}</prop>
<prop key="hibernate.c3p0.acquire_increment">${taxeng.hibernate.c3p0.acquire_increment}</prop>
<prop key="hibernate.c3p0.idle_test_period">${taxeng.hibernate.c3p0.idle_test_period}</prop>
<prop key="hibernate.c3p0.max_statements">${taxeng.hibernate.开发者_如何学Cc3p0.max_statements}</prop>
<prop key="hibernate.show_sql">false</prop>
</props>
</property>
Where each of the <prop key...1
> is a hibernate configuration key with which hibernate with create a c3p0 data source on my behalf.
However, I cannot find the hibernate configuration key which will set the testConnectionsOnCheckin property of the c3p0 datasource.
Is there such a key? If not, then should I be setting the entityManagers datasource directly and are there any tricks I should know before doing that?
Note: testConnectionsOnCheckout is not a viable option, which does have a corresponding hibernate configuration key.
There's only a subset of c3p0 properties that can be overridden like that:
http://www.mchange.com/projects/c3p0/index.html#hibernate-specific
For others (including testConnectionsOnCheckin) need to be overridden in c3p0.properties
精彩评论