Page 1 of 1

NHibernate - self-referencing relationship

Posted: Sun 12 Feb 2012 00:23
by acheven
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:



Posted: Wed 15 Feb 2012 14:28
by Shalex
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.

Posted: Mon 20 Feb 2012 06:33
by acheven
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.

Posted: Wed 22 Feb 2012 15:44
by Shalex
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?

Posted: Sat 03 Mar 2012 08:39
by acheven
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.