Search in sources :

Example 1 with Caipirinha

use of org.hibernate.jpa.test.pack.excludehbmpar.Caipirinha in project hibernate-orm by hibernate.

the class PackagedEntityManagerTest method testExcludeHbmPar.

@Test
public void testExcludeHbmPar() throws Exception {
    File testPackage = buildExcludeHbmPar();
    addPackageToClasspath(testPackage);
    try {
        emf = Persistence.createEntityManagerFactory("excludehbmpar", new HashMap());
    } catch (PersistenceException e) {
        emf.close();
        Throwable nested = e.getCause();
        if (nested == null) {
            throw e;
        }
        nested = nested.getCause();
        if (nested == null) {
            throw e;
        }
        if (!(nested instanceof ClassNotFoundException)) {
            throw e;
        }
        fail("Try to process hbm file: " + e.getMessage());
    }
    EntityManager em = emf.createEntityManager();
    Caipirinha s = new Caipirinha("Strong");
    em.getTransaction().begin();
    em.persist(s);
    em.getTransaction().commit();
    em.getTransaction().begin();
    s = em.find(Caipirinha.class, s.getId());
    em.remove(s);
    em.getTransaction().commit();
    em.close();
    emf.close();
}
Also used : EntityManager(javax.persistence.EntityManager) HashMap(java.util.HashMap) PersistenceException(javax.persistence.PersistenceException) Caipirinha(org.hibernate.jpa.test.pack.excludehbmpar.Caipirinha) File(java.io.File) Test(org.junit.Test)

Aggregations

File (java.io.File)1 HashMap (java.util.HashMap)1 EntityManager (javax.persistence.EntityManager)1 PersistenceException (javax.persistence.PersistenceException)1 Caipirinha (org.hibernate.jpa.test.pack.excludehbmpar.Caipirinha)1 Test (org.junit.Test)1