Java源码示例:org.hibernate.ejb.HibernateEntityManagerFactory

示例1
@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("#####################################################################");
}
 
示例2
public void testCanCastNativeEntityManagerFactoryToHibernateEntityManagerFactoryImpl() {
	EntityManagerFactoryInfo emfi = (EntityManagerFactoryInfo) entityManagerFactory;
	assertTrue(emfi.getNativeEntityManagerFactory() instanceof HibernateEntityManagerFactory);
}
 
示例3
/**
 * 根据jpa EntityManagerFactory 获取 hibernate SessionFactory API
 *
 * @param emf
 * @return
 */
public static SessionFactory getSessionFactory(EntityManagerFactory emf) {
    return ((HibernateEntityManagerFactory) emf).getSessionFactory();
}