use of org.eclipse.persistence.exceptions.PersistenceUnitLoadingException in project eclipselink by eclipse-ee4j.
the class EntityManagerJUnitTestSuite method testEMFBuiltWithSession.
// Bug 348766
public void testEMFBuiltWithSession() {
EntityManagerFactory emf = new EntityManagerFactoryImpl(JUnitTestCase.getServerSession());
EntityManager em = null;
try {
em = emf.createEntityManager(new HashMap());
} catch (Exception e) {
fail("Exception thrown while creating entity manager with entity manager factory created from session: " + e.getMessage());
}
beginTransaction(em);
Employee emp = new Employee();
em.persist(emp);
commitTransaction(em);
beginTransaction(em);
emp = em.find(Employee.class, emp.getId());
em.remove(emp);
commitTransaction(em);
Exception loadingException = null;
try {
JpaHelper.getEntityManagerFactory(emf).refreshMetadata(new HashMap());
} catch (PersistenceUnitLoadingException e) {
loadingException = e;
}
if (loadingException == null) {
fail("Proper exception not thrown when refreshing metadata: ");
}
}
Aggregations