Student student3 = createPersistedStudent(3L, "Bob", "Reimer", "C13Robert.Reimer",
new Integer(2013));
Student student4 = createPersistedStudent(4L, "Andrew", "Callow",
"C13Andrew.Callow", new Integer(2013));
Section section1 = new Section("M1A");
section1.setId(new Long(1L));
Section section2 = new Section("M2B");
section2.setId(new Long(2L));
section1.setCourse(course);
section2.setCourse(course);
Instructor instructor1 = createPersistedInstructor(5L, "David", "Roberts",
"David.Roberts");
Instructor instructor2 = createPersistedInstructor(6L, "Sarah", "O'Reilly",
"Sarah.OReilly");
// Set the Instructors for Sections 1 & 2
section1.setInstructor(instructor1);
section2.setInstructor(instructor2);
// Add Instructors to Course
course.addInstructor(instructor1);
course.addInstructor(instructor2);
// Add Students 1 & 2 to Section 1
section1.addStudent(student1);
student1.addSection(section1);
section1.addStudent(student2);
student2.addSection(section1);
course.addSection(section1);
course.addSection(section2);
// Add Students 3 & 4 to Section 2
section2.addStudent(student3);
student3.addSection(section2);
section2.addStudent(student4);
student4.addSection(section2);
tx.begin();
em.persist(section1);
em.persist(section2);