-->
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.  [ 1 post ] 
Author Message
 Post subject: Problems with mapping and composite id
PostPosted: Thu Jun 21, 2007 7:51 am 
Newbie

Joined: Thu Jun 14, 2007 8:10 am
Posts: 7
Hi,

I have a problem with mapping my Database-Structure to Objects.
I Have three tables:

- Mandant
    MandantId
    MandantBesch
- 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...?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.