title: Hibernate Caching does not improve performance
body: <p>My Application-context.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"
  ..
  xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
      ..
  default-autowire="byName"&gt;
  
  &lt;import resource="jms-context.xml" /&gt;
  
  &lt;context:property-placeholder location="classpath:res.properties" /&gt;
  
  &lt;context:annotation-config /&gt;
  &lt;context:component-scan base-package="..." /&gt;
  
  
  &lt;tx:annotation-driven transaction-manager="transactionManager" /&gt;
  
  &lt;bean id="PROPAGATION_REQUIRED"
      class="org.springframework.transaction.support.TransactionTemplate"&gt;
      &lt;property name="transactionManager" ref="transactionManager" /&gt;
      &lt;property name="propagationBehaviorName" value="PROPAGATION_REQUIRED" /&gt;
  &lt;/bean&gt;
  
  
  &lt;bean id="pooledDataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"
      destroy-method="close"&gt;
      &lt;property name="driverClass" value="${jdbc.database.driverClass}" /&gt;
      &lt;property name="jdbcUrl" value="${jdbc.database.url}" /&gt;
      &lt;property name="user" value="${jdbc.database.username}" /&gt;
      &lt;property name="password" value="${jdbc.database.password}" /&gt;
       ...
  &lt;/bean&gt;
  
  &lt;bean id="GLOBAL" class="oracle.jdbc.pool.OracleDataSource"
      destroy-method="close" p:URL="${jdbc.database.url}" p:user="${jdbc.database.username}"
      p:password="${jdbc.database.password}"&gt;
      &lt;property name="connectionCachingEnabled" value="true" /&gt;
      &lt;property name="connectionCacheProperties"&gt;
          &lt;util:map&gt;
              &lt;entry key="MinLimit" value="${jdbc.database.minLimit}" /&gt;
              &lt;entry key="MaxLimit" value="${jdbc.database.maxLimit}" /&gt;
              &lt;entry key="InitialLimit" value="${jdbc.database.initialLimit}" /&gt;
          &lt;/util:map&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
  
  &lt;bean id="global-tm" class="org.springframework.orm.jpa.JpaTransactionManager"&gt;
      &lt;property name="entityManagerFactory" ref="global-em" /&gt;
      &lt;property name="dataSource" ref="GLOBAL" /&gt;
  &lt;/bean&gt;
  
  &lt;bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"&gt;
      &lt;property name="entityManagerFactory" ref="global-em" /&gt;
  &lt;/bean&gt;
  
  &lt;bean id="jpaVendorAdapter"  class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"&gt;
      &lt;property name="showSql" value="false" /&gt;
      &lt;property name="generateDdl" value="false" /&gt;
      &lt;property name="databasePlatform" value="${jpa.hibernate.dialectClass}" /&gt;
  &lt;/bean&gt;
  
  &lt;bean id="global-em"
      class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
      p:packagesToScan="..." p:dataSource-ref="pooledDataSource"
      p:jpaVendorAdapter-ref="jpaVendorAdapter"&gt;
      &lt;property name="jpaPropertyMap"&gt;
          &lt;map&gt;
              &lt;entry key="hibernate.temp.use_jdbc_metadata_defaults" value="false" /&gt;
              &lt;entry key="hibernate.cache.region.factory_class"
                  value="org.hibernate.cache.ehcache.SingletonEhCacheRegionFactory" /&gt;
              &lt;entry key="hibernate.cache.use_second_level_cache" value="true" /&gt;
              &lt;entry key="hibernate.cache.use_query_cache" value="true" /&gt;
              &lt;entry key="javax.persistence.sharedCache.mode" value="ENABLE_SELECTIVE" /&gt;
              &lt;entry key="hibernate.generate_statistics" value="true" /&gt;
          &lt;/map&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
  
  &lt;bean   class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" /&gt;
  
  
   &lt;/beans&gt;
  </code></pre>
  
  <p>I have annotated my entities as follows :</p>
  
  <pre><code>import javax.persistence.Cacheable;
  import org.hibernate.annotations.Cache;
  
  @Cacheable
  @Cache(usage = org.hibernate.annotations.CacheConcurrencyStrategy.READ_ONLY)
  </code></pre>
  
  <p>The DSL in the Camel Route Builder is as follows:</p>
  
  <pre><code>from(fromURI)
       ...
      .policy(required)
      .bean(bean1, "proc") 
          ...
          .recipientList().method(recipientList, "endPoint")
      ...
      .end();
  </code></pre>
  
  <p>But I could not discern any tangible improvement. Am I missing something?</p>
  
  <p>My constraints are:</p>
  
  <ol>
  <li>I can not use Hibernate like (org.hibernate.annotations.Cache) directly in my code as my code needs to JPA compliant.</li>
  <li>My entities are annotated. So, beans can not be configured Cacheable via hbm.xml</li>
  </ol>