A: 

you could configure this as two relations. e.g.

<many-to-one name="ShippingAddress" class="Yournamespace.Address"/>
<many-to-one name="Address" class="Yournamespace.Address"/>
Joachim Kerschbaumer
Could you try to be a little bit more precise on how to do this? The Address Value object has no id, and it's stored in the same database. That's why I can't use simple relationships.
Tigraine
an ID never hurts as you don't have to use it, but nhibernate will be thankful!
Joachim Kerschbaumer
there can't be an Id because ShippingAddress and Address are both in the same table as Person. They are additional fields
Tigraine
why do you not use the same model you use in object space within your database? this would solve a lot of problems. two foreign keys and you're problem will be gone. it would be much cleaner btw.
Joachim Kerschbaumer
This represents a more normalized approach. Remove repeating data (address fields) from the Person table and put into an Address table and give it an identity. This will make things easier when you want to add Company.AddressId and Company.ShippingAddressId, for example.
Tim Scott
+1  A: 

Ok. I found the solution myself. The key is the construct in the XML configuration and it works rather nicely.

Here is how it's done:

<component name="Address" class="Address">
  <property name="Streetname"></property>
  <property name="Zip"></property>
  <property name="City"></property>
  <property name="Country"></property>
</component>

<component name="ShippingAddress" class="Address">
  <property name="Streetname" column="ShippingStreetname" />
  <property name="Zip" column="ShippingZip" />
  <property name="City" column="ShippingCity" />
  <property name="Country" column="ShippingCountry" />
</component>
Tigraine
if you store some entity to a database you should ALWAYS give it a unique ID. that makes life easier. then you can create an Address object (that maps to the Address table in the database corresponding to your config) and give its reference to your customers Address and ShippingAddress property.
Joachim Kerschbaumer

related questions