Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

Cache Always Misses (using Hibernate + EhCache)

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm using Hibernate with Spring framework, and trying to cache a query which is written through the CriteriaAPI. I've enabled the query cache and the 2nd Level cache. I've also set the setCacheable to true in that particular query. The problem is that hibernate session statistics show that it hits the database everything for the same query I'm running multiple times.

Here's the function with the criteria query


here's the caller function


spring-hibernate-context file



ehcache portion of this class



Log Excerpts:

I'm fairly new to Spring and Hibernate. I've read at least a dozen articles regarding this issue and did everything that I could. Also, I wrote a similar query using createQuery method, the result was the same. Any help would be appreciated.
 
What kind of corn soldier are you? And don't say "kernel" - that's only for this tiny ad:
professionally read, modify and write PDF files from Java
https://products.aspose.com/pdf/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!