Java Code Examples for org.hibernate.Cache#evictCollectionRegions()
The following examples show how to use
org.hibernate.Cache#evictCollectionRegions() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ToolsServiceImpl.java From ctsms with GNU Lesser General Public License v2.1 | 5 votes |
@Override protected void handleClearHibernateCache() throws Exception { Session session = sessionFactory.getCurrentSession(); if (session != null) { session.clear(); // internal cache clear } Cache cache = sessionFactory.getCache(); if (cache != null) { cache.evictCollectionRegions(); cache.evictDefaultQueryRegion(); cache.evictEntityRegions(); cache.evictQueryRegions(); } }
Example 2
Source File: HibernateUtils.java From es with Apache License 2.0 | 3 votes |
/** * 根据jpa EntityManagerFactory 清空二级缓存 包括: * 1、实体缓存 * 2、集合缓存 * 3、查询缓存 * 注意: * jpa Cache api 只能evict 实体缓存,其他缓存是删不掉的。。。 * * @param emf * @see org.hibernate.ejb.EntityManagerFactoryImpl.JPACache#evictAll() */ public static void evictLevel2Cache(EntityManagerFactory emf) { Cache cache = HibernateUtils.getCache(emf); cache.evictEntityRegions(); cache.evictCollectionRegions(); cache.evictDefaultQueryRegion(); cache.evictQueryRegions(); cache.evictNaturalIdRegions(); }