首先在.hbm.xml文件中加<cache usage="read-write"></cache>
最后在一个ehcache中加上下面的话,
最后你就要以做测试了,测试很简单,就是对同一个对像进行两次load以上的查询,如果控制台只打印一条sql语句,那就说明二级缓存配置成功了。这是最简单的方法。
对于list查询的二级缓存除了上面的步骤以外,还要在查询的时候加上query.setCacheable(true)这样就行了,
简单吧
至于上面的一些参数请自己找资料吧,我想效果出来了,理解起来也就会很容易 <<diskstore path="c:\\temp"></diskstore>
<cache font="" name="com.caitong.shopping.bean.Product"></cache><cache font="" name="com.caitong.shopping.bean.Product"></cache>cache name="com.caitong.shopping.bean.Product"
<cache name="com.caitong.shopping.bean.Product"></cache> maxElementsInMemory="500"
eternal="false"
timeToIdleSeconds="0"
timeToLiveSeconds="0"
overflowToDisk="true"
/>