1

During a job interview, a recruiter asked me about "how many cache levels are there in hibernate ?"

So I described the level 1 and 2.

He said correct but there is also a third level cache, for example cache the result of some table that doesn't change often like "CURRENCY" or "COUNTRY" and reload these tables each "12/24/ What time you want" hours.

I search about that, but I found nothing. So is there really a third level of cache or is it just some kind of features and if yes what's the name of this feature and how can I use it ?

UPDATE : You think he just talk about query.setCacheable(true) describe here ? mrbool.com/how-to-use-hibernate-query-cache/33439. But where can I define how long I put in cache the result of the query ? I suppose it doesn't cache for ever. If it's just that, i will rename the subject in "How define a duration for setCacheable with hibernate.

amdev
  • 3,010
  • 3
  • 35
  • 47

1 Answers1

2

There is a query cache in hibernate, but I am not sure if it can be called "third level" cache. I haven't heard such a name. Anyway, the query cache would be applicable for data which does not change often.

Its documentation can be found at: http://docs.jboss.org/hibernate/orm/5.0/userguide/html_single/Hibernate_User_Guide.html#caching-query

user140547
  • 7,750
  • 3
  • 28
  • 80
  • So you think he just talk about query.setCacheable(true) describe here ? http://mrbool.com/how-to-use-hibernate-query-cache/33439. But where can I define how long I put in cache the result of the query ? I suppose it doesn't cache for ever ^^. If it's just that, i will rename the subjet in "How define a duration for setCacheable with hibernate" – amdev Oct 11 '16 at 13:07
  • @amdev: the cache properties like timeout etc can be configured in the cache configuration, see for example: http://stackoverflow.com/questions/12524601/hibernate-ehcache-how-does-maxelementsinmemory-work But I guess if you have any further question regarding that, it would be better to ask a new question. – user140547 Oct 11 '16 at 13:23