@OneToMany(fetch = FetchType.EAGER)
@Cascade(value = {CascadeType.SAVE_UPDATE,CascadeType.ALL})
private List<Student> studentList; //集合列表
在service层中。更新主表前,先获取旧的集合子对象,然后在更新完主表后,对旧的集合对象进行删除
Classroom classroom=classroomDao.findById(id);
List<student> tempList=classroom.getStudentList();
classroom.setStudnetList(myNewStudnetList);
if(tempList!=null)
for(Student item: tempList)
{
studentDao.remove(item);
}