Search in sources :

Example 1 with Carpet

use of org.hibernate.jpa.test.pack.explodedpar.Carpet in project hibernate-orm by hibernate.

the class PackagedEntityManagerTest method testExplodedPar.

@Test
public void testExplodedPar() throws Exception {
    File testPackage = buildExplodedPar();
    addPackageToClasspath(testPackage);
    emf = Persistence.createEntityManagerFactory("explodedpar", new HashMap());
    EntityManager em = emf.createEntityManager();
    Carpet carpet = new Carpet();
    Elephant el = new Elephant();
    el.setName("Dumbo");
    carpet.setCountry("Turkey");
    em.getTransaction().begin();
    em.persist(carpet);
    em.persist(el);
    assertEquals(1, em.createNamedQuery("allCarpet").getResultList().size());
    assertNotNull(carpet.getId());
    em.remove(carpet);
    em.getTransaction().commit();
    em.close();
    emf.close();
}
Also used : EntityManager(javax.persistence.EntityManager) HashMap(java.util.HashMap) Elephant(org.hibernate.jpa.test.pack.explodedpar.Elephant) Carpet(org.hibernate.jpa.test.pack.explodedpar.Carpet) File(java.io.File) Test(org.junit.Test)

Aggregations

File (java.io.File)1 HashMap (java.util.HashMap)1 EntityManager (javax.persistence.EntityManager)1 Carpet (org.hibernate.jpa.test.pack.explodedpar.Carpet)1 Elephant (org.hibernate.jpa.test.pack.explodedpar.Elephant)1 Test (org.junit.Test)1