-->
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: Still problems with composite keys
PostPosted: Fri Dec 31, 2004 7:05 am 
Newbie

Joined: Sun Nov 21, 2004 6:20 pm
Posts: 11
Hi,

I still have problems with the mapping of my composite keys...please have a look to my previous postings.

Emanuel, I did look in the FAQ. I found two themes related two my problem. The first one is:

<I'm having trouble with a bidirectional association.
When you update a bidirectional association you must update both
ends.
parent.getChildren().add(child);
child.setParent(parent);
>

===> as you can see in the code provided in my previous posting, I updated both ends....

The second one I found was:
<<<<<<<How do I set a many-to-one association to an Entity having a composite id?
I have weird behavior or Exceptions when using a many-to-one association to an Entity having a composite id?

<composite-id ...>
<column name="id1" .../>
<column name="id2" .../>
</composite-id>

and in the other class

<many-to-one ...>
<column name="id1" .../>
<column name="id2" .../>
</many-to-one>

Be sure to keep columns in the exact same order between composite-id columns and many-to-one keys.>>>>>>>

====>This does not precisely meet my problem. The problem is, that the child class has a composite key, but only one part of the composite key is related to parent. In my example, the primary key of table OPTIONS consists of option_id and question_id, but only question_id is a foreign key to table QUESTION


====>I also read Chapter 16 once again. I see, that in this chapter, they save the children...hence it is assumed that the parent already exists......but I want to generate a parent, add some childs and then I just want to do session.save(parent).....

====>While reading chapter 16, I changed the one-to-many mapping in QUESTION (see my previous posting). I added inverse="true" and cascade="all". The effect was, that I do not get any exceptions, but the children are not saved to the Database.... ???? ....


**********************************************************
Anyway, in the meantime I have changed the DB-Design, so that I can work on, but I am really interested in this issue as I am sure that Hibernate is capable of maaping this and I suppose there is only one little thing wrong with my mapping....I would be glad if anybody can help me. THANKS!!!


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 03, 2005 11:09 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Are you sure you've implemented equals and hashcode correctly?

_________________
Emmanuel


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.