use of org.eclipse.persistence.jpa.test.basic.model.Dog in project eclipselink by eclipse-ee4j.
the class TestDB2Platform method createDogs.
private List<Dog> createDogs(EntityManagerFactory emf) throws Exception {
EntityManager em = emf.createEntityManager();
try {
ArrayList<Dog> dogList = new ArrayList<Dog>();
em.getTransaction().begin();
for (int i = 10; i > 0; i--) {
Dog aDog = new Dog();
aDog.setName("Dog " + i);
em.persist(aDog);
dogList.add(aDog);
}
em.getTransaction().commit();
return dogList;
} finally {
if (em.getTransaction().isActive()) {
em.getTransaction().rollback();
}
em.close();
}
}
Aggregations