-->
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: Composite key mapping using flattened relationships
PostPosted: Mon May 16, 2005 4:10 pm 
Newbie

Joined: Tue Apr 19, 2005 4:32 pm
Posts: 14
Hibernate version: 3

How can I map a relationship to an entity with a composite primary key where one of the foreign keys in the source entity comes from another relationship?

In other words ...

Let's say I have a class ClassB with a composite primary key:

ClassB (pk1, pk2)

and ClassA has a many-to-one relationship with ClassB such that

Code:
  ClassA.fk1 = ClassB.pk1
  ClassA.ref2.fk2 = ClassB.pk2

where ref2 is a many-to-one relationship to ClassC.

So I need a mapping that will look like:

Code:
<class name="ClassA" table="CLASSA">
...
  <many-to-one name="ref1" class="ClassB">
    <column name="PK1"/>
    <column-many-to-one name="ref2" class="ClassC" column="PK2"/>
  </many-to-one>
...
</class>


Since we don't have a column-many-to-one tag, I'm wondering if there's a good way to do this.

Thanks, Rishabh


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.