-->
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.  [ 4 posts ] 
Author Message
 Post subject: problem in composite-id when updating?
PostPosted: Tue Feb 17, 2004 5:14 am 
Beginner
Beginner

Joined: Fri Jan 23, 2004 5:08 am
Posts: 21
Hi! I have this kind of mapping:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<!--
Document : ContactRelationship.hbm.xml
Created on : December 19, 2003, 05:06 PM
Author : raymond
Description:
Purpose of the document follows.
-->

<hibernate-mapping >
<class name="com.eon.cms.vo.ContactRelationship" table="contact_relationship">
<composite-id>
<key-many-to-one name="contactA" column="contact_id1"/>
<key-many-to-one name="roleA" column="role_id1"/>
<key-many-to-one name="contactB" column="contact_id2"/>
<key-many-to-one name="roleB" column="role_id2"/>
</composite-id>
<property name="remark" length="500"/>
<property name="position" length="50"/>
</class>
</hibernate-mapping>

I have 4 foreign keys.I don't have any problem when saving the record but in updating the record, the data is never updated in the database.
In updating im using the session.update(), i also used session.saveOrUpdate(problem with session.saveOrUpdate is that it wiil add another record) Im using MySQL database. Could anyone help me on this?

thanks..


raymond


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 17, 2004 6:40 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
session.update() Should work, give more info and check that you've impelmented equals properly, and set ContactRelationship as seriabizable.

session.saveOrUpdate(), read the reference guide and the FAQ about that

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 17, 2004 7:14 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
You are most likely forgetting to flush or to commit.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 17, 2004 10:16 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
gloeglm wrote:
You are most likely forgetting to flush or to commit.

I think he did, insert works

_________________
Emmanuel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.