-->
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.  [ 2 posts ] 
Author Message
 Post subject: problem while updating
PostPosted: Mon Mar 24, 2008 11:46 am 
Newbie

Joined: Fri Nov 16, 2007 3:05 pm
Posts: 14
Hi Guys,

I am trying to execute the below code

trans = ses.beginTransaction();
Meeting met=new Meeting();
MeetingKey key = new MeetingKey();
key.setCaseId("test");
key.setEventSeq(1);
key.setGroupSeq(1);
key.setParticipantId(1);
key.setMeetingSeq(1);
met.setKey(key);
met.setName("Testname");
met.setMeetingDate(new Date());
met.setTime("12:00");
ses.update(met);
trans.commit();

The following two sql queries are generated in the backend.
update meeting set meeting_title=?, meeting_date=?, time_of_day=? where case_id=? and event_seq=? and group_seq=? and participant_id=? and meeting_seq=?
delete from meeting_individual where case_id=? and event_seq=? and group_seq=? and participant_id=? and meeting_seq=?

can any one tell me, why i am getting this delete query. I have given cascade="none" in my mapping document.

Hibernate version: Hibernate 3.1.2

Mapping documents: <class name="Meeting" table="meeting" lazy="false">
<composite-id name="key" class="MeetingKey">
<key-property name="caseId" type="string" column="case_id"/>
<key-property name="eventSeq" type="integer" column="event_seq"/>
<key-property name="groupSeq" type="integer" column="group_seq"/>
<key-property name="participantId" type="integer" column="participant_id"/>
<key-property name="meetingSeq" type="integer" column="meeting_seq"/>
</composite-id>
<property name="name" type="string" column="meeting_title"/>
<property name="meetingDate">
<column name="meeting_date" sql-type="date" ></column>
</property>
<property name="time" type="string" column="time_of_day"/>
<!--
<many-to-one name="chronologyText" class="ChronologyText" column="description_text_id" unique="true"/>
-->

<bag name="attendees" table="meeting_individual" fetch="join" cascade="none">
<key>
<column name="case_id"></column>
<column name="event_seq"></column>
<column name="group_seq"></column>
<column name="participant_id"></column>
<column name="meeting_seq"></column>
</key>
<many-to-many class="Individual" fetch="join">
<formula>case_id</formula>
<formula>event_seq</formula>
<formula>group_seq</formula>
<formula>participant_id</formula>
<column name="individual_seq"></column>
</many-to-many>
</bag>

</class>


Code between sessionFactory.openSession() and session.close():
trans = ses.beginTransaction();
Meeting met=new Meeting();
MeetingKey key = new MeetingKey();
key.setCaseId("test");
key.setEventSeq(1);
key.setGroupSeq(1);
key.setParticipantId(1);
key.setMeetingSeq(1);
met.setKey(key);
met.setName("Testname");
met.setMeetingDate(new Date());
met.setTime("12:00");
ses.update(met);
trans.commit();


Full stack trace of any exception that occurs:

Name and version of the database you are using:

The generated SQL (show_sql=true): update meeting set meeting_title=?, meeting_date=?, time_of_day=? where case_id=? and event_seq=? and group_seq=? and participant_id=? and meeting_seq=?
delete from meeting_individual where case_id=? and event_seq=? and group_seq=? and participant_id=? and meeting_seq=?


Debug level Hibernate log excerpt:


with thanks,
krishna


Top
 Profile  
 
 Post subject: problem while updating
PostPosted: Fri May 02, 2008 4:44 am 
Newbie

Joined: Fri Nov 16, 2007 3:05 pm
Posts: 14
Hi Guys,

This problem got resolved, when i used the inverse attribute in the
one to many association.


I hope this will be usefull.

thanks,
krishna.


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

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.