public void testOneToManyChildAtMultipleLevels_NoTxn() throws Exception {
testOneToManyChildAtMultipleLevels(NEW_EM_START_END);
}
private void testOneToManyChildAtMultipleLevels(StartEnd startEnd)
throws Exception {
HasOneToManyChildAtMultipleLevelsJPA pojo = new HasOneToManyChildAtMultipleLevelsJPA();
Book b1 = new Book();
pojo.setBooks(Utils.newArrayList(b1));
HasOneToManyChildAtMultipleLevelsJPA child = new HasOneToManyChildAtMultipleLevelsJPA();
Book b2 = new Book();
child.setBooks(Utils.newArrayList(b2));
pojo.setChild(child);
startEnd.start();
em.persist(pojo);
startEnd.end();
startEnd.start();
assertEquals(2, countForClass(Book.class));
pojo = em.find(HasOneToManyChildAtMultipleLevelsJPA.class, pojo.getId());
assertEquals(child.getId(), pojo.getChild().getId());
assertEquals(1, pojo.getBooks().size());
assertEquals(pojo.getBooks().get(0), b1);
assertEquals(child.getBooks().get(0), b2);
assertEquals(1, child.getBooks().size());
startEnd.end();
}