NHibernate-One 2 one association with different field names

Discussion of open issues, suggestions and bugs regarding Entity Developer - ORM modeling and code generation tool
Post Reply
acheven
Posts: 6
Joined: Fri 10 Feb 2012 09:13

NHibernate-One 2 one association with different field names

Post by acheven » Fri 10 Feb 2012 09:25

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

Shalex
Site Admin
Posts: 8242
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Wed 15 Feb 2012 14:21

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.

acheven
Posts: 6
Joined: Fri 10 Feb 2012 09:13

Post by acheven » Mon 20 Feb 2012 06:38

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)?

Shalex
Site Admin
Posts: 8242
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Wed 22 Feb 2012 15:50

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

Code: Select all

      
    
 

You can control the not-null setting via Association editor.

acheven
Posts: 6
Joined: Fri 10 Feb 2012 09:13

Post by acheven » Sat 03 Mar 2012 08:41

same as in my other post - there are extra properties window in column mapping. All good now, thank you.

Post Reply