简体   繁体   中英

Hibernate 2nd level cache strange settings

I am new to project and I have noticed that in production server we have such settings:

<prop key="hibernate.dialect">${db.dialect}</prop>
                <prop key="hibernate.show_sql">${show.sql}</prop>
                <prop key="hibernate.bytecode.use_reflection_optimizer">false</prop>
                <prop key="hibernate.cache.provider_class">Custom org.jboss.hibernate.jbc.cacheprovider.TreeCacheProvider</prop>
                <prop key="hibernate.cache.use_second_level_cache">false</prop>
                <prop key="hibernate.cache.use_query_cache">true</prop>

I doubt if this combination is ok:

 <prop key="hibernate.cache.use_second_level_cache">FALSE</prop>
 <prop key="hibernate.cache.use_query_cache">TRUE</prop>

What would be the purpose of caching query without using second level cache.. What could be the sense for setting provider_class in this case..

Moreover for me caching queries without caching objects may decrease efficiency.. isn't that right?

Query cache can be used stand-alone since it caches the ids of the query results, eliminating the need for performing the query again.

No one will be able to tell you if the benefit in your case is higher than the memory impact of storing all those queries, results and query parameters. Depending on the latency to your db and how huge your queries are results will vary but I personally would not use the query cache without a very good reason and only for a selected few query where query parameters don't fluctuate.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM