I enabled the second level cache in my application and configured the read-only startegy for two objects(FieldMetaData and FiledValidatorMetaData) which are having parent-child relation ship.I followed the below steps to enable the caching
1. Enabled the second-level caching and also specified cache provider in the hibernate.cfg.xml. 2.Added the below entry in *.hbm files <cache usage="read-only"/>, also specified the same for object associations. 3.provided ehcache.xml to the application with default configured values for both parent,child objects.
By looking at the log statmetns i am confused whether the caching is happening or not, because the same SQL SELECT statement is executing repeatatively.
Could anyone please provide the inputs. Please have a look at the below logs for detailed stack trace.
2009-08-03 17:15:21,653 http-8081-Processor24 DEBUG cache.CacheFactory - instantiating cache region: com.perceptive.ocf.metadata.FieldValidatorMetadata usage strategy: read-only 2009-08-03 17:15:21,653 http-8081-Processor24 WARN cache.CacheFactory - read-only cache configured for mutable class: com.perceptive.ocf.metadata.FieldValidatorMetadata 2009-08-03 17:15:21,747 http-8081-Processor24 DEBUG cache.CacheFactory - instantiating cache region: com.perceptive.ocf.metadata.FieldMetadata usage strategy: read-only 2009-08-03 17:15:21,747 http-8081-Processor24 WARN cache.CacheFactory - read-only cache configured for mutable class: com.perceptive.ocf.metadata.FieldMetadata 2009-08-03 17:15:23,762 http-8081-Processor24 DEBUG cache.CacheFactory - instantiating cache region: com.perceptive.ocf.metadata.FieldMetadata.validators usage strategy: read-only 2009-08-03 17:15:23,762 http-8081-Processor24 WARN cache.CacheFactory - read-only cache configured for mutable class: com.perceptive.ocf.metadata.FieldMetadata.validators 2009-08-03 17:15:23,762 http-8081-Processor24 WARN cache.EhCacheProvider - Could not find configuration [com.perceptive.ocf.metadata.FieldMetadata.validators]; using defaults. 2009-08-03 17:15:23,778 http-8081-Processor24 DEBUG cache.EhCacheProvider - started EHCache region: com.perceptive.ocf.metadata.FieldMetadata.validators 2009-08-03 17:15:27,778 http-8081-Processor24 DEBUG hibernate.SQL - select configs0_.name as name, configs0_.value as value21_ from CONFIGS configs0_ where configs0_.name=?
At First Hit-------------------> Below statments are logged
2009-08-03 17:19:14,187 http-8081-Processor25 DEBUG hibernate.SQL - select this_.ID as ID0_, this_.VERSION as VERSION0_0_, this_.OBJECT_NAME as OBJECT3_0_0_, this_.FIELD_NAME as FIELD4_0_0_, this_.DISPLAY_NAME as DISPLAY5_0_0_, this_.FIELD_TYPE as FIELD6_0_0_, this_.DEFAULT_VALUE as DEFAULT7_0_0_, this_.IS_INACTIVE as IS8_0_0_ from CUSTOM_FIELD_METADATA this_ where this_.OBJECT_NAME=? and this_.IS_INACTIVE=?2009-08-03 17:19:14,187 http-8081-Processor25 DEBUG cache.ReadOnlyCache - Caching: com.perceptive.ocf.metadata.FieldMetadata#9999 2009-08-03 17:19:14,203 http-8081-Processor25 DEBUG cache.ReadOnlyCache - Caching: com.perceptive.ocf.metadata.FieldMetadata#9996 2009-08-03 17:19:14,203 http-8081-Processor25 DEBUG cache.EhCache - key: com.perceptive.ocf.metadata.FieldMetadata.validators#99962009-08-03 17:19:14,203 http-8081-Processor25 DEBUG cache.EhCache - Element for com.perceptive.ocf.metadata.FieldMetadata.validators#9996 is null 2009-08-03 17:19:14,203 http-8081-Processor25 DEBUG hibernate.SQL - select validators0_.FIELD_METADATA_ID as FIELD6_1_, validators0_.ID as ID1_, validators0_.ID as ID0_, validators0_.VERSION as VERSION2_0_, validators0_.VALIDATOR_CLASS_NAME as VALIDATOR3_2_0_, validators0_.PARAM_ONE as PARAM4_2_0_, validators0_.PARAM_TWO as PARAM5_2_0_, validators0_.FIELD_METADATA_ID as FIELD6_2_0_ from CUSTOM_FIELD_VALIDATION validators0_ where validators0_.FIELD_METADATA_ID=? 2009-08-03 17:19:14,203 http-8081-Processor25 DEBUG cache.ReadOnlyCache - Caching: com.perceptive.ocf.metadata.FieldValidatorMetadata#4996 2009-08-03 17:19:14,203 http-8081-Processor25 DEBUG cache.ReadOnlyCache - Caching: com.perceptive.ocf.metadata.FieldMetadata.validators#9996 2009-08-03 17:19:14,203 http-8081-Processor25 DEBUG cache.EhCache - key: com.perceptive.ocf.metadata.FieldMetadata.validators#9999 2009-08-03 17:19:14,203 http-8081-Processor25 DEBUG cache.EhCache - Element for com.perceptive.ocf.metadata.FieldMetadata.validators#9999 is null 2009-08-03 17:19:14,203 http-8081-Processor25 DEBUG hibernate.SQL - select validators0_.FIELD_METADATA_ID as FIELD6_1_, validators0_.ID as ID1_, validators0_.ID as ID0_, validators0_.VERSION as VERSION2_0_, validators0_.VALIDATOR_CLASS_NAME as VALIDATOR3_2_0_, validators0_.PARAM_ONE as PARAM4_2_0_, validators0_.PARAM_TWO as PARAM5_2_0_, validators0_.FIELD_METADATA_ID as FIELD6_2_0_ from CUSTOM_FIELD_VALIDATION validators0_ where validators0_.FIELD_METADATA_ID=? 2009-08-03 17:19:14,203 http-8081-Processor25 DEBUG cache.ReadOnlyCache - Caching: com.perceptive.ocf.metadata.FieldMetadata.validators#9999
At Second Hit-------------------> Below statments are logged
2009-08-03 17:20:03,219 http-8081-Processor24 DEBUG hibernate.SQL - select this_.ID as ID0_, this_.VERSION as VERSION0_0_, this_.OBJECT_NAME as OBJECT3_0_0_, this_.FIELD_NAME as FIELD4_0_0_, this_.DISPLAY_NAME as DISPLAY5_0_0_, this_.FIELD_TYPE as FIELD6_0_0_, this_.DEFAULT_VALUE as DEFAULT7_0_0_, this_.IS_INACTIVE as IS8_0_0_ from CUSTOM_FIELD_METADATA this_ where this_.OBJECT_NAME=? and this_.IS_INACTIVE=?2009-08-03 17:20:03,235 http-8081-Processor24 DEBUG cache.ReadOnlyCache - Caching: com.perceptive.ocf.metadata.FieldMetadata#9999 2009-08-03 17:20:03,235 http-8081-Processor24 DEBUG cache.ReadOnlyCache - Caching: com.perceptive.ocf.metadata.FieldMetadata#9996 2009-08-03 17:20:03,235 http-8081-Processor24 DEBUG cache.EhCache - key: com.perceptive.ocf.metadata.FieldMetadata.validators#99962009-08-03 17:20:03,235 http-8081-Processor24 DEBUG cache.ReadOnlyCache - Cache hit: com.perceptive.ocf.metadata.FieldMetadata.validators#9996 2009-08-03 17:20:03,235 http-8081-Processor24 DEBUG cache.EhCache - key: com.perceptive.ocf.metadata.FieldValidatorMetadata#4996 2009-08-03 17:20:03,235 http-8081-Processor24 DEBUG cache.ReadOnlyCache - Cache hit: com.perceptive.ocf.metadata.FieldValidatorMetadata#4996 2009-08-03 17:20:03,235 http-8081-Processor24 DEBUG cache.EhCache - key: com.perceptive.ocf.metadata.FieldMetadata.validators#9999 2009-08-03 17:20:03,235 http-8081-Processor24 DEBUG cache.ReadOnlyCache - Cache hit: com.perceptive.ocf.metadata.FieldMetadata.validators#9999
thanks in advance Srinivas.
|