org.hibernate.ejb.HibernateEntityManagerFactory源码实例Demo

javax.persistence.Cache#org.hibernate.ejb.HibernateEntityManagerFactory源码实例Demo

下面列出了javax.persistence.Cache#org.hibernate.ejb.HibernateEntityManagerFactory 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: hibernate4-memcached   文件: QueryCacheTest.java
@Test
public void createQueryCacheAndEvictAllThenRetry() throws Exception {
	List<Author> beforeResults = getAuthorsWithQuery("Author query", "어느나라");

	log.warn("#####################################################################");

	HibernateEntityManagerFactory entityManagerFactory = (HibernateEntityManagerFactory) EntityTestUtils.getEntityManagerFactory();
	org.hibernate.Cache cache = entityManagerFactory.getSessionFactory().getCache();
	cache.evictEntityRegions();
	cache.evictQueryRegions();
	cache.evictDefaultQueryRegion();
	cache.evictCollectionRegions();

	log.warn("just eviected all.");
	List<Author> againResults = getAuthorsWithQuery("Author query again after evict all", "어느나라");

	assertThat(againResults).isEqualTo(beforeResults);
	log.warn("#####################################################################");
}
 
public void testCanCastNativeEntityManagerFactoryToHibernateEntityManagerFactoryImpl() {
	EntityManagerFactoryInfo emfi = (EntityManagerFactoryInfo) entityManagerFactory;
	assertTrue(emfi.getNativeEntityManagerFactory() instanceof HibernateEntityManagerFactory);
}
 
源代码3 项目: es   文件: HibernateUtils.java
/**
 * 根据jpa EntityManagerFactory 获取 hibernate SessionFactory API
 *
 * @param emf
 * @return
 */
public static SessionFactory getSessionFactory(EntityManagerFactory emf) {
    return ((HibernateEntityManagerFactory) emf).getSessionFactory();
}