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: one-to-many mapping via composite non-primary keys
PostPosted: Mon May 16, 2011 12:26 am 
Newbie

Joined: Sun May 15, 2011 9:58 pm
Posts: 1
I met such problem as below. If anyone has idea about that, please do me a favor.

I need to mapping a one-to-many relationship in hbm file to join two tables(say table_A and table_B) together. The expected class heirachy like:
class TableA {
....
List<TableB> tableb;
}

But the join is not based on the primary key of the table_A, but a composite non-primary key (column a2 and a3, the composite key is also an unique key). It is an existing business logic, so I can not change the join condition. So the join condition will be like: table_A.a2 = table_B.b2 and table_A.a3 = table_B.b3

I know with composite primary key, one-to-many mapping could be (suppose table_B still use column b2 and b3)

<bag name=" tableb" >
<key>
<colunm name="b2" >
< colunm name="b3">
</key>
<one-to-many class="TableB">
</bag>

For single non-primary key(suppose talbe_A a2 column), one-to-many mapping could be (suppose table_B uses column b2)
<bag name=" tableb" >
<key column name = "b2" property-ref="a2"/>
<one-to-many class="TableB">
</bag>

Now, my question comes. For the composite case, I need use property-ref to specify the non-primary keys, but I can't find anywhere to hold it: <key>, <column> or <one-to-many>section.

Anyone has any idea about that?

Thanks a lot.


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.