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);
}
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;
}
}
Aggregations