Hibernate – Assotations/Relationship : Delete Operation in Many To Many :
The following are the four steps:
1. Load student from database. - Student s = (Student)session.get(Student.class, 1001);
2. Read courses of the student into collection. - Set set = s.getCourse();
3. Read or load a course from a database. - Course c= (Course)session.get(Course.class, 902);
4. Remove course from the collection with in transaction. - set.remove(c);
<set name="students" cascade="all" table="STUDENTS_COURSES">
<key column = "CID" />
<many-to-many class="com.sada.Model.Student" column="STUID"></many-to-many>
</set>
<set name="course" cascade="all" table="STUDENTS_COURSES">
<key column = "STUID" />
<many-to-many class="com.sada.Model.Course" column="CID"></many-to-many>
</set>
Hibernate Examples Project Github Link : https://github.com/SadaLearningHub1/H...