Reputation: 13501
It would appear from searching around here and the web at large that it is not possible to implement EHCache as a write-behind cache for Hibernate, as that would require substantial changes to the Hibernate code.
Are there any other solutions (preferably open source) for a JPA provider that can 'transparently' hook into a write-behind cache implementation, and preferably one that can be distributed with something like Terracotta?
I've read that EclipseLink and Oracle Coherence can achieve this, but Coherence is sadly not a cheap solution!
Upvotes: 16
Views: 2605
Reputation: 17864
We did write a write-behind cache handler for Coherence, based on Hibernate.
What's stopping you from writing an EHCache CacheWriter using any JPA implementation, as described in http://ehcache.org/documentation/apis/write-through-caching. You could extend AbstractCacheWriter, and all you'll need to implement is write(net.sf.ehcache.Element), writeAll(java.util.Collection), delete(net.sf.ehcache.CacheEntry) and deleteAll(java.util.Collection).
Just make sure that it is completely independent of the surrounding transaction. Your application then writes to the cache alone, and does not use JPA anymore.
What are the problems you've encountered?
Upvotes: 5