質問

C3P0のtestConnectionOnCheckinプロパティを設定したいと思います。

しかし、C3P0 DataSourceは、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.c3p0.max_statements}</prop>
    <prop key="hibernate.show_sql">false</prop>
  </props>
</property>

それぞれ <prop key...1>私に代わってC3P0データソースを作成する冬眠がある冬眠構成キーです。

ただし、C3P0 DataSourceのTestConnectionSoncheckinプロパティを設定するHibernate構成キーは見つかりません。

そのような鍵はありますか?そうでない場合は、EntityManagers DataSourceを直接設定する必要があります。それを行う前に知っておくべきトリックはありますか?

注:testConnectionSoncheckoutは実行可能なオプションではなく、対応する冬眠構成キーがあります。

役に立ちましたか?

解決

そのようにオーバーライドできるC3P0プロパティのサブセットのみがあります。

http://www.mchange.com/projects/c3p0/index.html#hibernate特異的

他の人の場合(testConnectionSoncheckinを含む)、c3p0.propertiesでオーバーライドする必要があります

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top