use of jakarta.persistence.EntityManagerFactory in project spring-framework by spring-projects.
the class SharedEntityManagerCreatorTests method deferredQueryWithResultList.
@Test
public void deferredQueryWithResultList() {
EntityManagerFactory emf = mock(EntityManagerFactory.class);
EntityManager targetEm = mock(EntityManager.class);
Query query = mock(Query.class);
given(emf.createEntityManager()).willReturn(targetEm);
given(targetEm.createQuery("x")).willReturn(query);
given(targetEm.isOpen()).willReturn(true);
EntityManager em = SharedEntityManagerCreator.createSharedEntityManager(emf);
em.createQuery("x").getResultList();
verify(query).getResultList();
verify(targetEm).close();
}
use of jakarta.persistence.EntityManagerFactory in project jbosstools-hibernate by jbosstools.
the class JpaConfiguration method initialize.
void initialize() {
EntityManagerFactoryBuilderImpl entityManagerFactoryBuilder = HibernateToolsPersistenceProvider.createEntityManagerFactoryBuilder(persistenceUnit, getProperties());
EntityManagerFactory entityManagerFactory = entityManagerFactoryBuilder.build();
sessionFactory = (SessionFactory) entityManagerFactory;
metadata = entityManagerFactoryBuilder.getMetadata();
getProperties().putAll(entityManagerFactory.getProperties());
}
Aggregations