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 -~----------~----~----~----~------~----~------~--~---
