Hi,
I have a problem with mapping my Database-Structure to Objects.
I Have three tables:
- Mandant
- Filiale
MandantId (FK)
FilialeId
FilialeBesch
- Bezirk
MandantId (FK)
FilialeId (FK)
BezirkId
BezirkBesch
(Primary keys underlined)
with the following relations:
- Mandant - Filiale: n - m
- Filiale - Bezirk: n - m
The first mapping is no problem:
Code:
<class name="Mandant" table="Mandant">
<id name="id" column="MandanId" type="integer" />
<property name="besch" column="MandantBesch" type="string"/>
</class>
the second mapping is also not that difficult:
Code:
<hibernate-mapping default-lazy="false">
<class name="Filiale" table="Filiale">
<composite-id>
<key-property name="id" column="FilialeId" type="integer" />
<key-many-to-one name="mandant" class="Mandant" column="MandantId" />
</composite-id>
<property name="besch" column="FilialeBesch" type="string"/>
</class>
</hibernate-mapping>
Now i don't know how to map the third table.
I thought about using the composite-id with the key-many-to-one tag, but i don't know how to tell hibernate that the MandantId is sth. like a "foreign key in a foreign key" and is an object within the Filiale object...
Does anybody has an idea...?