title: Spring: hibernate + ehcache
body: <p>I'm working with a spring project using hibernate and look to implement second-level cache using ehcache. I see a number of approaches to this: </p>
  
  <ol>
  <li><p><a href="http://static.springsource.org/spring/docs/3.0.x/javadoc-api/org/springframework/cache/ehcache/package-frame.html" rel="noreferrer"><code>spring-modules-cache</code></a> which introduces the <code>@Cacheable</code> annotation</p></li>
  <li><p><a href="https://code.google.com/p/ehcache-spring-annotations/" rel="noreferrer"><code>ehcache-spring-annotations</code></a> a toolset which aims to be the successor of <code>spring-modules-cache</code>. </p></li>
  <li><p><a href="http://docs.jboss.org/hibernate/core/3.3/reference/en/html/performance.html#performance-cache" rel="noreferrer"><code>Hibernate cache</code></a> is nicely integrated into hibernate itself to perform caching using e.g., the <code>@Cache</code> annotation. </p></li>
  <li><p><a href="http://ehcache.org/documentation/samples.html#Using_Caches" rel="noreferrer"><code>Programmatic cache</code></a> using proxies. Annotation based config quickly becomes either limited or complex (e.g., several levels of annotation nesting)</p></li>
  </ol>
  
  <p>Personally I don't think <code>spring-modules-cache</code> is thorough enough, hence I would probably prefer consider the more actively developed <code>ehcache-spring-annotations</code>. <code>Hibernate cache</code> though seems to be most complete implementation (e.g., both read and write cache etc).  </p>
  
  <p>What would motivate which toolset to use? Please share your caching experience ... </p>