title: Spring datasource + JPA + Hibernate +c3p0 + ehCache
body: <p>I want to connect to my MySQL database using the folliowing libraries:</p>
  
  <ul>
  <li>spring: because my webapp use the spring-mvc framework</li>
  <li>hibernate (JPA): because it is a standard</li>
  <li>c3p0: for performance</li>
  <li>ehCache: for performance</li>
  </ul>
  
  <p>Here is my applicationContext.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
      xmlns:tx="http://www.springframework.org/schema/tx"
      xsi:schemaLocation="http://www.springframework.org/schema/beans
          http://www.springframework.org/schema/beans/spring-beans.xsd
          http://www.springframework.org/schema/tx
          http://www.springframework.org/schema/tx/spring-tx.xsd
          http://www.springframework.org/schema/context
          http://www.springframework.org/schema/context/spring-context.xsd"&gt;
  
      &lt;context:component-scan base-package="dao,service" /&gt;
  
      &lt;!-- Configuration du transaction manager --&gt;
      &lt;bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"&gt;
          &lt;property name="dataSource" ref="dataSource" /&gt;
          &lt;property name="packagesToScan" value="entity" /&gt;
  
          &lt;property name="jpaVendorAdapter"&gt;
              &lt;bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"/&gt;
          &lt;/property&gt;
          &lt;property name="jpaProperties"&gt;
              &lt;props&gt;
                  &lt;prop key="hibernate.hbm2ddl.auto"&gt;validate&lt;/prop&gt;
                  &lt;prop key="hibernate.dialect"&gt;org.hibernate.dialect.MySQL5Dialect&lt;/prop&gt;
                  &lt;prop key="current_session_context_class"&gt;thread&lt;/prop&gt;
                  &lt;prop key="hibernate.cache.provider_class"&gt;org.hibernate.cache.internal.NoCacheProvider&lt;/prop&gt;
                  &lt;!-- used for debug --&gt;
                  &lt;prop key="hibernate.show_sql"&gt;true&lt;/prop&gt;
                  &lt;!-- EhCache --&gt;
                  &lt;prop key="hibernate.cache.provider_configuration_file_resource_path"&gt;classpath:ehcache.xml&lt;/prop&gt;
                  &lt;prop key="hibernate.cache.region.factory_class"&gt;org.hibernate.cache.ehcache.EhCacheRegionFactory&lt;/prop&gt;
                  &lt;prop key="hibernate.cache.provider_class"&gt;org.hibernate.cache.SingletonEhCacheProvider&lt;/prop&gt;
                  &lt;prop key="hibernate.cache.use_second_level_cache"&gt;true&lt;/prop&gt;
                  &lt;prop key="hibernate.cache.use_query_cache"&gt;true&lt;/prop&gt;
                  &lt;prop key="hibernate.generate_statistics"&gt;true&lt;/prop&gt;
                  &lt;!-- configuration pool via c3p0, see https://community.jboss.org/wiki/HowToConfigureTheC3P0ConnectionPool --&gt;
                  &lt;prop key="hibernate.connection.provider_class"&gt;org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider&lt;/prop&gt; 
                      &lt;prop key="hibernate.c3p0.acquire_increment"&gt;1&lt;/prop&gt; &lt;prop key="hibernate.c3p0.max_size"&gt;5&lt;/prop&gt; 
                      &lt;prop key="hibernate.c3p0.max_statements"&gt;100&lt;/prop&gt; &lt;prop key="hibernate.c3p0.min_size"&gt;1&lt;/prop&gt; 
                      &lt;prop key="hibernate.c3p0.timeout"&gt;100&lt;/prop&gt; &lt;prop key="hibernate.checkoutTimeout"&gt;1000&lt;/prop&gt; 
                      &lt;prop key="hibernate.c3p0.idleConnectionTestPeriod"&gt;30&lt;/prop&gt; &lt;prop key="hibernate.c3p0.preferredTestQuery"&gt;SELECT 1
                  &lt;/prop&gt;
              &lt;/props&gt;
          &lt;/property&gt;
      &lt;/bean&gt;
  
      &lt;!-- Configuration de la BDD --&gt;
      &lt;bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"&gt;
          &lt;property name="driverClassName" value="com.mysql.jdbc.Driver" /&gt;
          &lt;property name="url" value="jdbc:mysql://localhost:3306/mydb?autoReconnect=true" /&gt;
          &lt;property name="username" value="user" /&gt;
          &lt;property name="password" value="password" /&gt;
      &lt;/bean&gt;
  
      &lt;bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"&gt;
          &lt;property name="entityManagerFactory" ref="entityManagerFactory" /&gt;
      &lt;/bean&gt;
  
      &lt;tx:annotation-driven /&gt;
  
      &lt;bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" /&gt;
  &lt;/beans&gt;
  </code></pre>
  
  <p>I dont get any error but I'm not sure that c3p0 and ehCache are working :/</p>