1、SessionFactory对象的evict(Class arg0)方法可以从二级缓存中清除指定的持久化类的所有缓存对象,并释放其占用的资源。如:

sessionFactory.evict(Category.class);

2、SessionFactory对象的evictCollection(String arg0)方法可以从二级缓存中清除指定的集合对象的缓存。如:

sessionFactory.evictCollection("com.kkoolerter.example.Category.products");

3、SessionFactory对象的evictEntity(String arg0,Serializable arg1)方法可以从二级缓存中清除指定的持久化类的所有缓存对象。如:

sessionFacotry.evictEntity("com.kkoolerter.beans.Category",new Integer(1));