-->
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: Collection mapping without identifier
PostPosted: Thu Apr 16, 2009 8:00 am 
Newbie

Joined: Thu Apr 16, 2009 3:55 am
Posts: 3
Hello I have this table structure (can't change it)

Table A
ID(Key) RefCode
1 A
2 A
3 B

Table B
RefCode(Key) Value
A 99
A 188
B 300

In want the collection of value from Table B where TableA.RefCode = TableB.RefCode

EntityA.ListeEntityB => EntityA(ID= 1) must return two EntityB ((Value=99);(Value=188)

The problem in this structure is that the relation is non on primary key

So if I write this mapping :

<class name="EntityA" table="TableA">
<id name="Id" column="ID" unsaved-value="0">
<generator class="native" />
</id>

<bag name="ListeEntityB" table="TableB">
<key column="RefCode"></key>
<one-to-many class="EntityB" />
</bag>
</class>

nhibernate does not make the relation
TableA.RefCode = TableB.RefCode But
TableA.ID = TableB.RefCode (because ID is the primary key of Table A)

How can in configure nhibernate to map a collection not from the ID of the source table TableA(ID) but to another column (in my case RefCode) ) ?

Thanks


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.