Thanks for the reply. Is it possible to make a relationship on 2 columns
without having subclasses? Because the whole point of this structure is that
each address row/instance can be assigned as any type (home, work, billing),
e.g.: "same as above address" checkbox.

And regarding lazy load, I did some google and found out that lazy loading
is NOT apparently supported for one-one relationship, particularly for
non-mandatory one. And for the reason mentioned (nhibernate needs to know in
advance whether the other side of the relation exists before assigning a
proxy).

Does this (still) hold true? Loading all addresses for each customer in a
huge search can be really expensive. Does anyone has any trick or pointer to
do lazy-load in one-to-one (or many to one) relationships in NH?

Thanks

On Fri, Feb 13, 2009 at 4:04 AM, Ben Scheirman <[email protected]> wrote:

> address_type is your discriminator column, then subclass Address for the
> various types.
> Perhaps there's a better way, but that should work.
>
>
> On Wed, Feb 11, 2009 at 8:36 PM, Hendry Luk <[email protected]> wrote:
>
>> Hi there,
>>
>> I'm wondering how the scenario below can be mapped through NH. It's a
>> legacy entity structure.
>>
>> public class Customer
>> {
>>      public Address HomeAddress {get;set;}
>>      public Address WorkAddress {get; set;}
>>      public Address BillingAddress {get;set;}
>> }
>>
>> Unfortunately, it's also mapped to legacy database structure, where we
>> have an associative table:
>> create table CUSTOMERS_ADDRESSES
>> (
>>     customer_id int,
>>     address_id int,
>>     address_type varchar(10)
>> )
>>
>> Where address_type holds 'HOME' or 'WORK' or 'BILLING'.
>>
>> I.e., for clarity, home-address is populated with this query:
>> select * from ADDRESSES where address_id in (select address_id from
>> CUSTOMERS_ADDRESSES where customer_id=? and address_type = 'HOME'
>>
>> How do we map this association in nhibernate mapping?
>>
>> And my real concern is about lazyload and nulls. Each of the addresses is
>> optional and may therefore be null. And if we're to use lazy-load, they can
>> never be null (instead, a proxy instance, which i suspect will throw
>> ObjectNotFoundException when the actual loading kicks in).
>>
>> Any advice?
>>
>> Thanks
>> Hendry
>>
>>
>>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
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