NHibernate - self-referencing relationship

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 - self-referencing relationship

Post by acheven » Sun 12 Feb 2012 00:23

When modelling a self-referencing relationship in ED for Nhibernate (as 1-many), the hbm file is generated with not-null="true" option for the 1 part of the relationship.

This, of course, does not work as the top level element would not have a parent.

Is there a property that I can set on End1 generated property of the relationship to force not-null=false.

Example:



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

Post by Shalex » Wed 15 Feb 2012 14:28

acheven wrote:When modelling a self-referencing relationship in ED for Nhibernate (as 1-many), the hbm file is generated with not-null="true" option for the 1 part of the relationship.
Please set the Not Null attribute of the column to False when setting column mapping in Association Editor.

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

Post by acheven » Mon 20 Feb 2012 06:33

This does not seem to be available for Navigation Properties, which is what I get when I create self-referencing association... The underlying database column is most definitely nullable.

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

Post by Shalex » Wed 22 Feb 2012 15:44

Setting the Not Null attribute of the column to False in the Columns mapping section of Association Editor produces the following entry in *.hbml:

Code: Select all

    
      
    
Is that what you mean?

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

Post by acheven » Sat 03 Mar 2012 08:39

Yes, thank you. I just realised that you can control the column properties in association editor. The (...) symbol only appears when you focus in the cell with your mouse and it was not obvious that column mapping has additional properties until I clicked on it. Problem solved.

Post Reply