Search in sources :

Example 1 with JuniorScientist

use of org.eclipse.persistence.testing.models.jpa.advanced.compositepk.JuniorScientist in project eclipselink by eclipse-ee4j.

the class AdvancedCompositePKJunitTest method testReadJuniorScientist.

public void testReadJuniorScientist() {
    JuniorScientist jScientist;
    jScientist = createEntityManager().find(JuniorScientist.class, m_jScientistPK);
    assertTrue("Error on reading back the junior scientist.", jScientist != null);
}
Also used : JuniorScientist(org.eclipse.persistence.testing.models.jpa.advanced.compositepk.JuniorScientist)

Example 2 with JuniorScientist

use of org.eclipse.persistence.testing.models.jpa.advanced.compositepk.JuniorScientist in project eclipselink by eclipse-ee4j.

the class AdvancedCompositePKJunitTest method testCreateScientists.

public void testCreateScientists() {
    EntityManager em = createEntityManager();
    beginTransaction(em);
    try {
        Department department = em.merge(em.find(Department.class, m_departmentPK));
        Cubicle cubicle1 = new Cubicle("G");
        em.persist(cubicle1);
        Scientist scientist1 = new Scientist();
        scientist1.setFirstName("Guy");
        scientist1.setLastName("Pelletier");
        scientist1.setCubicle(cubicle1);
        department.addScientist(scientist1);
        em.persist(scientist1);
        Cubicle cubicle2 = new Cubicle("T");
        em.persist(cubicle2);
        Scientist scientist2 = new Scientist();
        scientist2.setFirstName("Tom");
        scientist2.setLastName("Ware");
        scientist2.setCubicle(cubicle2);
        department.addScientist(scientist2);
        em.persist(scientist2);
        Cubicle cubicle3 = new Cubicle("G");
        em.persist(cubicle3);
        Scientist scientist3 = new Scientist();
        scientist3.setFirstName("Gordon");
        scientist3.setLastName("Yorke");
        scientist3.setCubicle(cubicle3);
        department.addScientist(scientist3);
        em.persist(scientist3);
        Cubicle cubicle4 = new Cubicle("J");
        em.persist(cubicle4);
        JuniorScientist jScientist = new JuniorScientist();
        jScientist.setFirstName("Junior");
        jScientist.setLastName("Sao");
        jScientist.setCubicle(cubicle4);
        department.addScientist(jScientist);
        em.persist(jScientist);
        commitTransaction(em);
        m_scientist1PK = scientist1.getPK();
        m_scientist2PK = scientist2.getPK();
        m_scientist3PK = scientist3.getPK();
        m_jScientistPK = jScientist.getPK();
    } catch (RuntimeException e) {
        if (isTransactionActive(em)) {
            rollbackTransaction(em);
        }
        closeEntityManager(em);
        throw e;
    }
}
Also used : EntityManager(jakarta.persistence.EntityManager) Department(org.eclipse.persistence.testing.models.jpa.advanced.compositepk.Department) Scientist(org.eclipse.persistence.testing.models.jpa.advanced.compositepk.Scientist) JuniorScientist(org.eclipse.persistence.testing.models.jpa.advanced.compositepk.JuniorScientist) Cubicle(org.eclipse.persistence.testing.models.jpa.advanced.compositepk.Cubicle) JuniorScientist(org.eclipse.persistence.testing.models.jpa.advanced.compositepk.JuniorScientist)

Aggregations

JuniorScientist (org.eclipse.persistence.testing.models.jpa.advanced.compositepk.JuniorScientist)2 EntityManager (jakarta.persistence.EntityManager)1 Cubicle (org.eclipse.persistence.testing.models.jpa.advanced.compositepk.Cubicle)1 Department (org.eclipse.persistence.testing.models.jpa.advanced.compositepk.Department)1 Scientist (org.eclipse.persistence.testing.models.jpa.advanced.compositepk.Scientist)1