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!!!
|