ehcache を使用してキャッシュしようとしているルックアップ テーブルにデータのリストがあります。キャッシュにデータが適切に取り込まれていることに気付きましたが、条件クエリで .add( Restrictions.like("name", "Fritz%")) を使用すると、2 番目のレベルのキャッシュにヒットしていないように見えます. Id だけでなく文字列値を使用してキャッシュを参照するように ehcache を構成する方法はありますか?
クエリの例
List cats = sess.createCriteria(Cat.class)
.add( Restrictions.like("name", "Fritz%") )
.setCacheable(true)
.list();
hibernate.cfg.xml
<!-- Enable Second-Level Cache and Query Cache Settings -->
<property name="hibernate.cache.use_second_level_cache">true</property>
<property name="hibernate.cache.use_query_cache">true</property>
<property name="hibernate.cache.region.factory_class">net.sf.ehcache.hibernate.EhCacheRegionFactory</property>
<property name="hibernate.generate_statistics">false</property>
実在物
@Entity
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class Cat implements Serializable {
private String name;
ログ
stat.Statistics HQL: null, time: 1ms, rows: 0
cache.StandardQueryCache caching query results in region: org.hibernate.cache.StandardQueryCache; timestamp=5516849224093696
cache.UpdateTimestampsCache Pre-invalidating space [vehicle_trim_level]
cache.UpdateTimestampsCache Pre-invalidating space [vehicle_model]
cache.UpdateTimestampsCache Invalidating space [vehicle_model], timestamp: 5516849224110081
cache.UpdateTimestampsCache Invalidating space [vehicle_trim_level], timestamp: 5516849224110081
cache.UpdateTimestampsCache Pre-invalidating space [vehicle]
stat.ConcurrentStatisticsImpl Logging statistics....
stat.ConcurrentStatisticsImpl start time: 1346820087066
stat.ConcurrentStatisticsImpl sessions opened: 57
stat.ConcurrentStatisticsImpl sessions closed: 56
stat.ConcurrentStatisticsImpl transactions: 1211
stat.ConcurrentStatisticsImpl successful transactions: 1153
stat.ConcurrentStatisticsImpl optimistic lock failures: 0
stat.ConcurrentStatisticsImpl flushes: 1153
stat.ConcurrentStatisticsImpl connections obtained: 1212
stat.ConcurrentStatisticsImpl statements prepared: 2444
stat.ConcurrentStatisticsImpl statements closed: 2444
stat.ConcurrentStatisticsImpl second level cache puts: 540
stat.ConcurrentStatisticsImpl second level cache hits: 0
stat.ConcurrentStatisticsImpl second level cache misses: 0
stat.ConcurrentStatisticsImpl entities loaded: 125
stat.ConcurrentStatisticsImpl entities updated: 710
stat.ConcurrentStatisticsImpl entities inserted: 475
stat.ConcurrentStatisticsImpl entities deleted: 0
stat.ConcurrentStatisticsImpl entities fetched (minimize this): 0
stat.ConcurrentStatisticsImpl collections loaded: 8
stat.ConcurrentStatisticsImpl collections updated: 0
stat.ConcurrentStatisticsImpl collections removed: 0
stat.ConcurrentStatisticsImpl collections recreated: 0
stat.ConcurrentStatisticsImpl collections fetched (minimize this): 8
stat.ConcurrentStatisticsImpl queries executed to database: 719
stat.ConcurrentStatisticsImpl query cache puts: 680
stat.ConcurrentStatisticsImpl query cache hits: 494
stat.ConcurrentStatisticsImpl query cache misses: 680
stat.ConcurrentStatisticsImpl max query time: 10ms
cache.UpdateTimestampsCache Pre-invalidating space [vehicle_trim_level]
cache.UpdateTimestampsCache Invalidating space [vehicle], timestamp: 5516849228881920
cache.UpdateTimestampsCache Invalidating space [vehicle_trim_level], timestamp: 5516849228881920