Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What is the proper configuration for OpenJPA using ehcache as a distributed second level cache?

 
Hunter Stern
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using OpenJPA with ehcache as a distributed second level cache. My application is based on Spring MVC. I have enabled distributed caching using the <terracotta/> element within the <cache> elements of my ehcache.xml. My problem is that I am seeing cache misses when I repeat the same query against the query cache. Also, I see cache misses when I retrieve objects. I believe my configuration is somehow not right. Can anyone post a workable configuration or verify the one I am using?

ehcache.xml



persistence.xml



Query Code




Java TagCloutItem class



A related issue is that when I query an object using EntityManager.find on one jvm, the full object graph (the Entity relations) don't seem to get cached although the primary object does. For example, on jvm1 I load a User object. The next HTTP request calls EntityManager.find on jvm2 and loads the related Entity data using the cached User object. However, on the next failover, the related Entity data gets loaded again (User.getRelatedObjects()), as though this data was not put in cache and distributed to jvm1's second level JPA cache.

Please let me know if any of this is not clear.

Thanks,

H
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic