Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If you <strong>look at the stack trace</strong>, you'll realize that the invalid <code>dogMissingName</code> record is still hanging around in the session's batched insertion buffer, even after the first attempt to perform the insertion failed. Calling <code>Dog.FindFirst()</code> later in the same session <strong>re-triggers an internal <code>Flush()</code></strong> (which attempts once again the failed insert.)</p> <p>From <a href="http://knol.google.com/k/fabio-maulo/nhibernate-chapter-9/1nr4enxv3dpeq/12#9(2E)7(2E)2(2E)(C2)(A0)Committing_the_database_transaction" rel="nofollow noreferrer">section 9.6</a> of the documentation:</p> <blockquote> <p>From time to time the ISession will execute the SQL statements needed to synchronize the ADO.NET connection's state with the state of objects held in memory. This process, flush, occurs by default at the following points</p> <ul> <li>from some invocations of Find() or Enumerable()</li> <li>from NHibernate.ITransaction.Commit()</li> <li>from ISession.Flush()</li> </ul> </blockquote> <p>Additionally, from <a href="http://knol.google.com/k/fabio-maulo/nhibernate-chapter-9/1nr4enxv3dpeq/12#9(2E)7(2E)2(2E)(C2)(A0)Committing_the_database_transaction" rel="nofollow noreferrer">section 9.7.2</a> of the documentation:</p> <blockquote> <p>If you rollback the transaction you should immediately close and discard the current session to ensure that NHibernate's internal state is consistent.</p> </blockquote> <p>Simply <strong>moving <code>using (new SessionScope())</code> <em>inside</em> the outermost <code>try</code>/<code>catch</code></strong> may be a viable workaround (the initial insertion will fail, raise an exception which will take you out of the <code>SessionScope</code>, likely triggering a second failure on the same insert, failure which you finally <code>catch</code> -- also see <a href="http://markmail.org/message/5qh4uiqemxq56dbz" rel="nofollow noreferrer">"data is not flushed on SessionScope.Flush()"</a> in <code>com.googlegroups.castle-project-users</code>.).</p> <p>Alternatively, if you don't want to close the session, you should be able to <strong>simply <a href="http://knol.google.com/k/fabio-maulo/nhibernate-chapter-9/1nr4enxv3dpeq/12#9(2E)6(2E)(C2)(A0)Flush" rel="nofollow noreferrer">change the session default flush behaviour</a></strong> (see the <code>FlushMode</code> class) so that it never flushes unless <code>Flush()</code> is called explicitly (e.g. before committing.) Note that managing flushing in this way <strong>will get complex and error-prone very quickly</strong>, though.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload