In my Hibernate Application i have Timetable(parent) classtable(child) is their.
My first operation is insert into Timetable and using this timetable many classtable inserted. Like onetomany Relation.
But i'm facing the Problem : first Timetable inserted and classtable inserted and again timetable and classtable..........so on..
But my intention is only one Timetable and Many classtable.
Hear is my Code...in Timetable
@OneToMany(mappedBy = "timetable",cascade={CascadeType.ALL})
private Set<ClassTableVO> classtable;
And ClassTable
@ManyToOne(cascade={CascadeType.ALL})
@JoinColumn(name = "COURSE_TABLE_ID")
private TimetableVO timetable;
And if we remove (cascade={CascadeType.ALL})
it give Exception like object references an unsaved transient instance
Please help me..
Edit:
In my Hibernate i'm using JPA EntityManager class
userDAO.createEvent(timetableVO);//this loop only one time executed
------
-----
for(---){
userDAO.createClassTable(classTable);
}
and above method have two line of code in both two methods..
entityManager.merge(classTable);//
entityManager.flush();