クエリ キャッシュを使用するようにアプリを構成しました。
休止状態の設定:
hibernate.cache.region.factory_class=net.sf.ehcache.hibernate.SingletonEhCacheRegionFactory
hibernate.cache.use_query_cache=true
EHCache 構成:
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="ehcache.xsd" updateCheck="false" monitoring="autodetect" dynamicConfig="false">
<defaultCache
maxEntriesLocalHeap="10000"
eternal="false"
timeToIdleSeconds="120"
timeToLiveSeconds="120"
maxEntriesLocalDisk="10000000"
diskExpiryThreadIntervalSeconds="120"
memoryStoreEvictionPolicy="LRU">
<persistence strategy="localTempSwap"/>
</defaultCache>
<cache name="query.Dictionary.CountriesList"
maxEntriesLocalHeap="10000"
maxEntriesLocalDisk="1000"
eternal="false"
timeToLiveSeconds="86400">
<persistence strategy="localTempSwap" />
</cache>
</ehcache>
ダオ:
Criteria query = session.createCriteria(DictionaryCountry.class)
.setCacheable(true)
.setCacheRegion("query.Dictionary.CountriesList")
.addOrder(Order.asc("name"));
ここで、初めて国のリストを入力しようとすると、標準クエリが作成され(select * from ... where ... )
ます。しかし、2回目に実行すると、キャッシュから取得する代わりに、アプリはid sqlクエリで多くのgetを実行し(select * from ... where id = ? )
ます...
それは正常な動作ですか?
ありがとうございました