i have a student object and student has set of phone numbers which is stored in student_phone table. i have given the mapping as <set name="studentPhoneNumbers" table="STUDENT_PHONE" cascade="delete-orphan"> <key column="STUDENT_ID" /> <many-to-many column="PHONE_ID" unique="true" class="com.test.tutorials.Phone" /> </set> i have loaded the student object and i have given session.setReadOnly(student,false); after loading the student i have done student.getStudentPhoneNumbers().removeAll(Collection....); after that we are updating the student name and calls session.update(student).
when it issues the update , the following queries are issued. Hibernate: update Student set STUDENT_NAME=?, STUDENT_ADDRESS=? where STUDENT_ID=? Hibernate: delete from STUDENT_PHONE where STUDENT_ID=? Hibernate: delete from PHONE where PHONE_ID=?
My doubt is why it issues Delete to Phone table. is session.setReadOnly(student,true); why it dosent do and update to student table. only the following query is issued delete from STUDENT_PHONE where STUDENT_ID=?
can anyone suggest the reason
|