use of javax.persistence.EntityManagerFactory in project hibernate-orm by hibernate.
the class OrmVersionTest method testOrm1.
@Test
public void testOrm1() {
PersistenceUnitInfoImpl pui = new PersistenceUnitInfoImpl("orm1-test", "1.0").addMappingFileName("org/hibernate/jpa/test/jee/valid-orm-1.xml");
HibernatePersistenceProvider hp = new HibernatePersistenceProvider();
EntityManagerFactory emf = hp.createContainerEntityManagerFactory(pui, Collections.EMPTY_MAP);
try {
// exception if not entity
emf.getMetamodel().entity(Lighter1.class);
} finally {
emf.close();
}
}
use of javax.persistence.EntityManagerFactory in project hibernate-orm by hibernate.
the class OrmVersionTest method testOrm2.
@Test
public void testOrm2() {
PersistenceUnitInfoImpl pui = new PersistenceUnitInfoImpl("orm2-test", "2.0").addMappingFileName("org/hibernate/jpa/test/jee/valid-orm-2.xml");
HibernatePersistenceProvider hp = new HibernatePersistenceProvider();
EntityManagerFactory emf = hp.createContainerEntityManagerFactory(pui, Collections.EMPTY_MAP);
try {
// exception if not entity
emf.getMetamodel().entity(Lighter.class);
} finally {
emf.close();
}
}
use of javax.persistence.EntityManagerFactory in project hibernate-orm by hibernate.
the class ColumnWithExplicitReferenceToPrimaryTableTest method testColumnAnnotationWithExplicitReferenceToPrimaryTable.
@Test
@TestForIssue(jiraKey = "HHH-8539")
public void testColumnAnnotationWithExplicitReferenceToPrimaryTable() {
final PersistenceUnitDescriptorAdapter pu = new PersistenceUnitDescriptorAdapter() {
@Override
public List<String> getManagedClassNames() {
return Arrays.asList(AnEntity.class.getName());
}
};
final Map settings = new HashMap();
settings.put(AvailableSettings.HBM2DDL_AUTO, "create-drop");
EntityManagerFactory emf = Bootstrap.getEntityManagerFactoryBuilder(pu, settings).build();
emf.close();
}
use of javax.persistence.EntityManagerFactory in project hibernate-orm by hibernate.
the class SecondMetadataTest method testBaseOfService.
@Test
public void testBaseOfService() throws Exception {
EntityManagerFactory emf = entityManagerFactory();
assertNotNull(emf.getMetamodel());
assertNotNull(emf.getMetamodel().entity(DeskWithRawType.class));
assertNotNull(emf.getMetamodel().entity(EmployeeWithRawType.class));
assertNotNull(emf.getMetamodel().entity(SimpleMedicalHistory.class));
assertNotNull(emf.getMetamodel().entity(SimplePerson.class));
}
use of javax.persistence.EntityManagerFactory in project hibernate-orm by hibernate.
the class TransactionCommitFailureTest method testConfiguredInterceptor.
@Test
public void testConfiguredInterceptor() {
Map settings = basicSettings();
EntityManagerFactory emf = Bootstrap.getEntityManagerFactoryBuilder(new PersistenceUnitDescriptorAdapter(), settings).build();
EntityManager em = emf.createEntityManager();
try {
em.getTransaction().begin();
transactionFailureTrigger.set(true);
em.getTransaction().commit();
} catch (RollbackException e) {
assertEquals(COMMIT_FAILURE, e.getCause().getMessage());
} finally {
if (em.getTransaction() != null && em.getTransaction().isActive()) {
em.getTransaction().rollback();
}
em.close();
emf.close();
}
}
Aggregations