org.hibernate.ejb.HibernateEntityManagerFactory Java Examples

The following examples show how to use org.hibernate.ejb.HibernateEntityManagerFactory. 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: QueryCacheTest.java    From hibernate4-memcached with Apache License 2.0 6 votes vote down vote up
@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("#####################################################################");
}
 
Example #2
Source File: HibernateEntityManagerFactoryIntegrationTests.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
public void testCanCastNativeEntityManagerFactoryToHibernateEntityManagerFactoryImpl() {
	EntityManagerFactoryInfo emfi = (EntityManagerFactoryInfo) entityManagerFactory;
	assertTrue(emfi.getNativeEntityManagerFactory() instanceof HibernateEntityManagerFactory);
}
 
Example #3
Source File: HibernateUtils.java    From es with Apache License 2.0 2 votes vote down vote up
/**
 * 根据jpa EntityManagerFactory 获取 hibernate SessionFactory API
 *
 * @param emf
 * @return
 */
public static SessionFactory getSessionFactory(EntityManagerFactory emf) {
    return ((HibernateEntityManagerFactory) emf).getSessionFactory();
}