-->
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: Association not on primary key
PostPosted: Thu Aug 11, 2005 4:29 am 
Newbie

Joined: Thu Aug 11, 2005 4:21 am
Posts: 2
I have following situation:

Entity Company:
ID (PK)
OtherUniqueID (FK)
Name
...


Entity Reports:
ID (PK)
Year
Month
OtherUniqueID (FK)
...

Each Company can have 0-n Reports. The reports are not related to the Company through the company's PK but throught the field OtherUniqueID, which in the Company entity is unique.

How can I map this in NHibernate?

Thanks for any suggestions!


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 11, 2005 4:05 pm 
Beginner
Beginner

Joined: Wed Jun 29, 2005 10:40 am
Posts: 30
Location: denver, co
This can be done via the property-ref attribute of the many-to-one element. This attribute specifies the property of the "one" side to create the relation on.

Example:
Code:

<many-to-one column="OtherUniqueID" outer-join="false" name="EntityCompany" property-ref="OtherUniqueID" class="Namespace.EntityCompany, AssemblyName"/>



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.