Hi,
i know there are a lot of threads related to this topic but I couldn't get it to work so I want to ask for explicit help.
I have tables looking like that:
Table A:
id1: part of primary key
id2: part of primary key
fields...
Table B:
id1: primary key
fields...
Now I want to map those tables on one class:
Class Fields:
id1
id2
fields from A
fields from B
Its a many to one assiociation therefore there would be much more object representations than entrys in Table A.
My actuall mapping looks like this:
Code:
<class name="..." table="Table A">
<composite-id name="id" class="...">
<key-property name="id1" column="..." type="integer"/>
<key-property name="id2" column="..." type="integer"/>
</composite-id>
<property name="..." column="..." type="..."/>
<join table="Table B">
<key column="id1" property-ref="id1" />
<property name="..." column="..." type="..."/>
</join>
</class>
I get the following error on executing:
Quote:
Foreign key (FK2448B63037B2D18C:TableB [id1])) must have same number of columns as the referenced primary key (Table A [id1,id2])
Without property-ref it's absolutly clear to me why this happens. With property-ref not! I do give him a column to join on, am I not?
Is there something I am missing?
How do I get the class mapped like I want it to be?
Is hibernate able to map a class like this?
I know the database schema is inappropriate but its a legacy system and it is absolutly no option to change it.
I appreciate every hint for a working solution.