title: NHibernate one-to-one mapping where second table data can be null
body: <p>I have an existing database with the table Transactions in it. I have added a new table called TransactionSequence where each transaction will ultimately have only one record. We are using the sequence table to count transactions for a given account. I have mapped this as a one-to-one mapping where TransactionSequence has a primary key of TransactionId. </p>
  
  <p>The constraint is that there is an instead of trigger on the transaction table does not allow updates of cancelled or posted transactions. </p>
  
  <p>So, when the sequence is calculated and the transaction is saved, NHibernate tries to send an update on the transaction like 'UPDATE Transaction SET TransactionId = ? WHERE TransactionId = ?'. But this fails because of the trigger. How can I configure my mapping so that NHibernate will not try to update the Transaction table when a new TransactionSequence table is inserted?</p>
  
  <p>Transaction mapping:</p>
  
  <pre><code>&lt;class name="Transaction" table="Transaction" dynamic-update="true" select-before-update="true"&gt;
      &lt;id name="Id" column="ID"&gt;
          &lt;generator class="native" /&gt;
      &lt;/id&gt;
  
      &lt;property name="TransactionTypeId" access="field.camelcase-underscore" /&gt;
      &lt;property name="TransactionStatusId" column="DebitDebitStatus" access="field.camelcase-underscore" /&gt;
  
      &lt;one-to-one name="Sequence" class="TransactionSequence" fetch="join"
                   lazy="false" constrained="false"&gt;      
      &lt;/one-to-one&gt;
  &lt;/class&gt;
  </code></pre>
  
  <p>And the sequence mapping:</p>
  
  <pre><code>&lt;class name="TransactionSequence" table="TransactionSequence" dynamic-update="true"&gt;
      &lt;id name="TransactionId" column="TransactionID" type="Int32"&gt;
          &lt;generator class="foreign"&gt;
              &lt;param name="property"&gt;Transaction&lt;/param&gt;
          &lt;/generator&gt;
      &lt;/id&gt;
  
      &lt;version name="Version" column="Version" unsaved-value="-1" access="field.camelcase-underscore" /&gt;
  
      &lt;property name="SequenceNumber" not-null="true" /&gt;
  
      &lt;one-to-one name="Transaction" 
                  class="Transaction" 
                  constrained="true" 
                  foreign-key="fk_Transaction_Sequence" /&gt;
  
  &lt;/class&gt;
  </code></pre>
  
  <p>Any help would be greatly appreciated...</p>