Search in sources :

Example 1 with PersistenceUnitLoadingException

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: ");
    }
}
Also used : EntityManager(jakarta.persistence.EntityManager) JpaEntityManager(org.eclipse.persistence.jpa.JpaEntityManager) Employee(org.eclipse.persistence.testing.models.jpa.advanced.Employee) PersistenceUnitLoadingException(org.eclipse.persistence.exceptions.PersistenceUnitLoadingException) HashMap(java.util.HashMap) EntityManagerFactory(jakarta.persistence.EntityManagerFactory) JpaEntityManagerFactory(org.eclipse.persistence.jpa.JpaEntityManagerFactory) EntityManagerFactoryImpl(org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl) TestProblemException(org.eclipse.persistence.testing.framework.TestProblemException) ValidationException(org.eclipse.persistence.exceptions.ValidationException) EclipseLinkException(org.eclipse.persistence.exceptions.EclipseLinkException) EntityExistsException(jakarta.persistence.EntityExistsException) OptimisticLockException(jakarta.persistence.OptimisticLockException) QueryException(org.eclipse.persistence.exceptions.QueryException) TransactionRequiredException(jakarta.persistence.TransactionRequiredException) IntegrityException(org.eclipse.persistence.exceptions.IntegrityException) EntityNotFoundException(jakarta.persistence.EntityNotFoundException) SQLException(java.sql.SQLException) RollbackException(jakarta.persistence.RollbackException) NoResultException(jakarta.persistence.NoResultException) PersistenceException(jakarta.persistence.PersistenceException) PersistenceUnitLoadingException(org.eclipse.persistence.exceptions.PersistenceUnitLoadingException)

Aggregations

EntityExistsException (jakarta.persistence.EntityExistsException)1 EntityManager (jakarta.persistence.EntityManager)1 EntityManagerFactory (jakarta.persistence.EntityManagerFactory)1 EntityNotFoundException (jakarta.persistence.EntityNotFoundException)1 NoResultException (jakarta.persistence.NoResultException)1 OptimisticLockException (jakarta.persistence.OptimisticLockException)1 PersistenceException (jakarta.persistence.PersistenceException)1 RollbackException (jakarta.persistence.RollbackException)1 TransactionRequiredException (jakarta.persistence.TransactionRequiredException)1 SQLException (java.sql.SQLException)1 HashMap (java.util.HashMap)1 EclipseLinkException (org.eclipse.persistence.exceptions.EclipseLinkException)1 IntegrityException (org.eclipse.persistence.exceptions.IntegrityException)1 PersistenceUnitLoadingException (org.eclipse.persistence.exceptions.PersistenceUnitLoadingException)1 QueryException (org.eclipse.persistence.exceptions.QueryException)1 ValidationException (org.eclipse.persistence.exceptions.ValidationException)1 EntityManagerFactoryImpl (org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl)1 JpaEntityManager (org.eclipse.persistence.jpa.JpaEntityManager)1 JpaEntityManagerFactory (org.eclipse.persistence.jpa.JpaEntityManagerFactory)1 TestProblemException (org.eclipse.persistence.testing.framework.TestProblemException)1