Q: Why hibernate second level cach?
A: Improve performent and cluster.
Q: How many kinds of second level?
A: EHCache, OSCache, SwarmCache.
Q: What can be catch?
A: Properties and Object.
Q: How to implement second level cach?
A:
1. Config in hibernate.cfg.xml:
<property name="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</property>
<property name="transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</property> <property name="transaction.manager_lookup_class">org.hibernate.transaction.WeblogicTransactionManagerLookup</property>
(while write cache existed)
2. Edit default or specified cache strategies in ehcache.xml
3. Define cach class(in hibernate.cfg.xml(usage, include) : cache-class, cache-collections(certain object's collection properties), in *.hbm.xml: cach)