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.

3 thoughts on “EhCache implementation of OpenJPA caching

  1. Craig Andrews has contributed the OpenJPA Ehcache plugin to the ehcache project. It is available at

    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.

  2. Pingback:

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.