You can map billing and home with where clauses:

<set batch-size="20" where="ADDRESS_TYPE = 0" cascade="save-update" 
inverse="true" lazy="true" name="Billings" mutable="false">

        <key column="`ADD_ID`" />       <one-to-many class="Address" />
</set>


<set batch-size="20" where="ADDRESS_TYPE = 1" cascade="save-update" 
inverse="true" lazy="true" name="Homes" mutable="false">

        <key column="`ADD_ID`" />       <one-to-many class="Address" />
</set>


<set batch-size="20" cascade="save-update" inverse="true" lazy="true" 
name="Homes">     <key column="`ADD_ID`" />       <one-to-many class="Address" 
/></set>


Your columns and tables may be different, of course.

RP

On Monday, October 8, 2012 9:57:39 AM UTC+1, H.Alex wrote:
>
> I would have this:
>
> Address table
> Address types table
> Person table
>
> AddressPersonLink table
> {
> AddressId
> AddressTypeId
> PersonId
> }
>
> Then every person would have it's addreses which would map to the 
> AddressPersonLink table, and home/billing addresses would not be mapped but 
> i would do them like:
>
> public virtual Address HomeAddress
> {
> get { return this.Addresses.Where(p=> p.AddressType == 
> "Home").SingleOrDefault();
> set { this.Addresses.Remove(this.HomeAddress); this.Addresses.Add(value); }
> }
>
> Then if you need some historical data you can easily add to the 
> PersonAddressLink table the dates active from and to.
>
> On Sunday, October 7, 2012 10:37:04 PM UTC+2, barbara wrote:
>>
>> I have a class "person" with (amongst the others) these properties:
>> - home address (of type address)
>> - billing address (of type address)
>> - addresses (of type List<address>, it contains all the known addresses 
>> of the person)
>>
>> the collection "addresses" holds reference to all the known addresses of 
>> the person, including the two explicitly referenced by the two other 
>> properties. Or maybe the person has just one address that is referenced by 
>> "home address", "billing address" and "addresses".
>> How should I map this class? And also, how can I be shure that in the 
>> last case the "three instances" point to the only row in the "addresses" 
>> table?
>>
>> Thanks in advance!
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/nhusers/-/p_gi_AM34l0J.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en.

Reply via email to