Home > Uncategorized > EhCache implementation of OpenJPA caching

EhCache implementation of OpenJPA caching

I usually use Hibernate, which supports a number of caching implementations (such as EhCache, oscache, JBoss, etc). My most recent project had a dependency on a product which has a dependency on OpenJPA, and OpenJPA only has it’s own built in implementations of a query cache and a data cache. I like to have one caching implementation in my project, so having two (OpenJPA’s for itself, and EhCache for everything else) annoyed me. So I had to fix it.

I started with Pinaki Poddar’s implementation of a Coherence provided OpenJPA data cache. I changed it to use EhCache, adjusted the unit tests, and then added a query cache implementation. To use it, add a dependency on the openjpa-ehcache, then set OpenJPA’s “openjpa.QueryCache” to “ehcache” and “openjpa.DataCacheManager” to ehcache. That’s it!

The code can be compiled with Maven. Simply run “mvn install”.

My code, like EhCache and OpenJPA, is licensed under the Apache Public License 2.0. Get it here.

CC BY-SA 4.0 EhCache implementation of OpenJPA caching by Craig Andrews is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.

Categories: Uncategorized Tags:
  1. March 16th, 2009 at 12:19 | #1
    I made a bug requesting this implementation be included in OpenJPA at https://issues.apache.org/jira/browse/OPENJPA-980
  2. July 14th, 2009 at 03:42 | #2
    Craig Andrews has contributed the OpenJPA Ehcache plugin to the ehcache project. It is available at http:ehcache.sf.net/documentation/openjpa_plugin.html.

    Kevin Sutter from the OpenJPA project has agreed to integrate this module into the OpenJPA site.

    As the maintainer of ehcache, I am pleased to facilitate this in order to promote a first class caching implementation for OpenJPA users.

  1. December 27th, 2010 at 01:21 | #1