Page 1 of 1
NHibernate-One 2 one association with different field names
Posted: Fri 10 Feb 2012 09:25
by acheven
Hi,
Until "property-ref="PropertyNameFromAssociatedClass"" is implemented in the entity developer for NHibernate, (
http://ayende.com/blog/3960/nhibernate- ... one-to-one), how would I map an optional association in the following scenario:
Customer.BillingAddress
[customer].[billing_address_id] [addresses].[address_id]
Cheers,
Andrei
Posted: Wed 15 Feb 2012 14:21
by Shalex
Please open Association editor, select the Constrained checkbox on any end of your one-to-one association, select Separate Foreign Key, and set column mapping for the foreign key. As a result, Entity Developer will add the property-ref attribute to your association in *.hbml.
Posted: Mon 20 Feb 2012 06:38
by acheven
Yes, I saw this, but this creates a non-nullable association, I was asking how to model an optional relationship. I.e. if customer does not always have a billing address ([customer].[billing_address_id] is nullable in DB)?
Posted: Wed 22 Feb 2012 15:50
by Shalex
Shalex wrote:Please open Association editor, select the Constrained checkbox on any end of your one-to-one association, select Separate Foreign Key, and set column mapping for the foreign key. As a result, Entity Developer will add the property-ref attribute to your association in *.hbml.
leads to
You can control the
not-null setting via Association editor.
Posted: Sat 03 Mar 2012 08:41
by acheven
same as in my other post - there are extra properties window in column mapping. All good now, thank you.