2.15
<hibernate-mapping>
<class name="test.child" table="child">
<cache usage="read-write"/>
<id name="childid" type="string">
<column name="childid" length="200"/>
<generator class="uuid.hex"/>
</id>
<property name="name"/>
<property name="email"/>
</class>
</hibernate-mapping>
Configuration cfg=new Configuration().configure();
sf=cfg.buildSessionFactory();
//new SchemaExport(cfg).create(true,true);
Session s=sf.openSession();
Transaction t=s.beginTransaction();
Iterator iter=s.iterate("select c from child as c");
t.commit();
s.close();
14:02:36,084 INFO SettingsFactory:128 - cache provider: net.sf.hibernate.cache.
OSCacheProvider
14:02:36,144 INFO Configuration:1080 - instantiating and configuring caches
14:02:36,565 INFO SessionFactoryImpl:119 - building session factory
14:02:37,426 INFO SessionFactoryObjectFactory:82 - no JNDI name configured
14:02:37,436 INFO UpdateTimestampsCache:35 - starting update timestamps cache a
t region: net.sf.hibernate.cache.UpdateTimestampsCache
14:02:37,446 INFO QueryCache:39 - starting query cache at region: net.sf.hibern
ate.cache.QueryCache
Hibernate: select child0_.childid as x0_0_ from child child0_
Hibernate: select child0_.childid as childid0_, child0_.name as name0_, child0_.
email as email0_ from child child0_ where child0_.childid=?
.... .............
mysql4.0.1 alpha:
Debug level Hibernate log excerpt:
Hibernate query database everytime when I run the code.Why oscache can't work?
My hibernate.properties:
Code:
#hibernate.cache.provider_class net.sf.ehcache.hibernate.Provider
#hibernate.cache.provider_class net.sf.hibernate.cache.EmptyCacheProvider
#hibernate.cache.provider_class net.sf.hibernate.cache.HashtableCacheProvider
#hibernate.cache.provider_class net.sf.hibernate.cache.TreeCacheProvider
hibernate.cache.provider_class net.sf.hibernate.cache.OSCacheProvider
#hibernate.cache.provider_class net.sf.hibernate.cache.JCSCacheProvider
#hibernate.cache.provider_class net.sf.hibernate.cache.SwarmCacheProvider
I also place the cache.ccf in the src and class . The code in cache.ccf is:
Code:
# DEFAULT CACHE REGION (memory cache)
jcs.default=DC
jcs.default.cacheattributes=org.apache.jcs.engine.CompositeCacheAttributes
jcs.default.cacheattributes.MaxObjects=2000
jcs.default.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory.lru.LRUMemoryCache
jcs.default.elementattributes=org.apache.jcs.engine.ElementAttributes
jcs.default.elementattributes.IsEternal=false
jcs.default.elementattributes.MaxLifeSeconds=240
jcs.default.elementattributes.IdleTime=1800
jcs.default.elementattributes.IsSpool=true
jcs.default.elementattributes.IsRemote=false
jcs.default.elementattributes.IsLateral=false
# System CACHE REGION
jcs.system.groupIdCache=DC
jcs.system.groupIdCache.cacheattributes=org.apache.jcs.engine.CompositeCacheAttributes
jcs.system.groupIdCache.cacheattributes.MaxObjects=10000
jcs.system.groupIdCache.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory.lru.LRUMemoryCache
#Auxiliary CACHE (disk cache)
#jcs.auxiliary.DC=org.apache.jcs.auxiliary.disk.indexed.IndexedDiskCacheFactory
#jcs.auxiliary.DC.attributes=org.apache.jcs.auxiliary.disk.indexed.IndexedDiskCacheAttributes
#jcs.auxiliary.DC.attributes.DiskPath=cache
Why Hibernate query database everytime and it can't use oscache?
Thks!