title: nhibernate one-to-one mapping and not-null="false"?
body: <p>How to create one-to-one relation using NHibernate where other side could be a NULL?
  For example, I have a Banner entity that has a relation to Image entity like this:</p>
  
  <pre><code>&lt;class name="Banner" table="Banner"&gt;
      &lt;id name="Id" type="Int64" unsaved-value="0"&gt;
          &lt;generator class="native" /&gt;
      &lt;/id&gt;
  
      &lt;many-to-one name="Image" unique="true" column="ImageId" not-null="false"/&gt;
  
      &lt;!-- check: In the example this property was without inverse attribute --&gt;
      &lt;set name ="BannerSlideSet" fetch="subselect" inverse="true"&gt;
          &lt;key column="Banner_ID" foreign-key="FK_Banner_BannerSlide" not-null="false" /&gt;
          &lt;one-to-many class="BannerSlide"/&gt;
      &lt;/set&gt;
  &lt;/class&gt;
  </code></pre>
  
  <p>So, Image can be null for a Banner entity.
  I create one banner entity with no image without any issues.
  In DB I have </p>
  
  <pre><code>--------------
  ID  | ImageId
  --------------
   1  | NULL
  </code></pre>
  
  <p>After that, I'm trying to create second Banner instance with no Image as well and get the following error:</p>
  
  <blockquote>
    <p>NHibernate.Exceptions.GenericADOException: could not insert:
    [Domain.Entities.Banner][SQL: INSERT INTO Banner (ImageId) VALUES (?);
    select SCOPE_IDENTITY()] ---> System.Data.SqlClient.SqlException:
    Violation of UNIQUE KEY constraint 'UQ_<em>Banner</em>_7516F70DE6141471'.
    Cannot insert duplicate key in object 'dbo.Banner'. The duplicate key
    value is ().</p>
  </blockquote>
  
  <p>I guess, it happens because I have unique constraint on one-to-many relation between banner and image entities and several Banner instances can't have several NULL values in ImageId field. Question: how I would achieve one-to-nullableone relation with in NHinerbate?</p>
  
  <p>Thanks!</p>