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: mapping multiple tables using another table
PostPosted: Thu Oct 27, 2005 7:19 pm 
Newbie

Joined: Tue Oct 25, 2005 6:23 pm
Posts: 2
I am mapping 3 many-to-many relationships with a common table. I've been trying to get this to map, but am not sure it is possible. If anyone knows of a way to handle this complex mapping, I'd greatly appreciate help. I have the following table structures simplified to their primary keys:

TableA:
<PK>col1

TableB:
<PK>col2

TableC:
<PK>col3
<PK>col4

TableD:
<PK>col1
<PK>col2
<PK>col3
<PK>col4
<PK>col5

TableD contains foreign keys to all other tables and has an additional key column to make a 5 column primary key. I was able to get D mapped to A and B, but can't figure out how to get D mapped to C(so the POJO for TableD will have a reference to a related item in C). If anyone know how this can be done

Thanks,
Dave


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 27, 2005 7:44 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
it'd look something like:
Code:
<class name="D">
    <composite-id ...>
        <key-many-to-one name="a" class="A" column="col1"/>
        <key-many-to-one name="b" class="B" column="col2"/>
        <key-many-to-one name="c" class="C">
            <column name="col3"/>
            <column name="col4"/>
        </key-many-to-one>
        <key-property name="?" column="col5"/>
    </composite-id>
</class>


yummy! ;)

Have a look at:
http://www.hibernate.org/hib_docs/v3/reference/en/html/mapping.html#mapping-declaration-compositeid

and

http://www.hibernate.org/hib_docs/v3/reference/en/html/components.html#components-compositeid


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.