-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: problem in updates after readOnly queries
PostPosted: Thu Jan 13, 2011 5:22 am 
Newbie

Joined: Thu Jan 13, 2011 5:15 am
Posts: 1
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.