title: Configuring Hibernate with HikariCP
body: <p>Because of problems with c3p0 connection pool, I want to see the alternatives and decide which one might be more usable in my case. HikariCP looks very promising, but there is no documentation how to use it with Hibernate.</p>
  
  <p>So far I am using c3p0 as follows:</p>
  
  <pre><code>&lt;bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"&gt;
      &lt;property name="persistenceUnitName" value="persistenceUnit"/&gt;
      &lt;property name="jpaProperties"&gt;
          &lt;props&gt;
              &lt;prop key="hibernate.dialect"&gt;${database.dialect}&lt;/prop&gt;
              &lt;prop key="hibernate.hbm2ddl.auto"&gt;${database.structure}&lt;/prop&gt;
              &lt;prop key="hibernate.connection.url"&gt;${database.connection}&lt;/prop&gt;
              &lt;prop key="hibernate.connection.username"&gt;${database.username}&lt;/prop&gt;
              &lt;prop key="hibernate.connection.password"&gt;${database.password}&lt;/prop&gt;
              &lt;prop key="hibernate.connection.driver_class"&gt;${database.driver}&lt;/prop&gt;
              &lt;prop key="hibernate.connection.shutdown"&gt;true&lt;/prop&gt;
              &lt;prop key="hibernate.connection.writedelay"&gt;0&lt;/prop&gt;
              &lt;prop key="hibernate.connection.characterEncoding"&gt;UTF-8&lt;/prop&gt;
              &lt;prop key="hibernate.connection.charSet"&gt;UTF-8&lt;/prop&gt;
              &lt;prop key="hibernate.show_sql"&gt;${database.show_sql}&lt;/prop&gt;
              &lt;prop key="hibernate.format_sql"&gt;false&lt;/prop&gt;
              &lt;prop key="hibernate.ejb.metamodel.generation"&gt;disabled&lt;/prop&gt;
              &lt;!-- Use the C3P0 connection pool provider --&gt;
              &lt;prop key="hibernate.connection.provider_class"&gt;org.hibernate.connection.C3P0ConnectionProvider&lt;/prop&gt;
              &lt;prop key="hibernate.c3p0.min_size"&gt;5&lt;/prop&gt;
              &lt;prop key="hibernate.c3p0.max_size"&gt;30&lt;/prop&gt;
              &lt;prop key="hibernate.c3p0.timeout"&gt;300&lt;/prop&gt;
              &lt;prop key="hibernate.c3p0.max_statements"&gt;50&lt;/prop&gt;
              &lt;prop key="hibernate.c3p0.idle_test_period"&gt;600&lt;/prop&gt;
          &lt;/props&gt;
      &lt;/property&gt;
  </code></pre>
  
  <p>Can someone point me how to configure HikariCP in such way?</p>