Question

I successfully setup hibernate 3.6.2 to use second level cache, using the ehcache 2.5.2 library.

I can see in logs and statistics that entities populate second level caches and that the queries that I want to be cacheable are cached.

As I use XML configuration in hbm.xml files, considered classes have a

<cache usage="read-write"/>

sub-element.

The following properties are defined :

hibernate.cache.use_second_level_cache=true
hibernate.cache.use_query_cache=org.hibernate.cache.EhCacheProvider
hibernate.cache.use_query_cache=true

However, hibernate does not cache the queries it generates to perform lazy loading of entities or collections. I can see them executed over and over, with the same parameters, in postgresql logs.

Is there a configuration to perform to do so ?

Was it helpful?

Solution

You just need to make sure that your classes and relatons are mapped using @Cache annotation.

You can read more about it here:

http://docs.jboss.org/hibernate/core/3.6/reference/en-US/html_single/#performance-cache-mapping

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top