title: Why does NHibernate throw "StaleObjectStateException"?
body: <p>I am writing project and using NHibernate 3.1</p>
  
  <p>SimpleTest:</p>
  
  <pre><code>Forum forum = Session.CreateCriteria&lt;Forum&gt;().Add(Restrictions.Eq("UrlName", "reportabug")).UniqueResult&lt;Forum&gt;();
  forum.TopicsCount++;
  IForumRepository forumRepository = new ForumRepository(SessionFactory);
  forumRepository.Update(forum);
  
  public virtual void Update(TEntity entity)
  {
      if (!session.Transaction.IsActive)
      {
          TResult result;
          using (var tx = session.BeginTransaction())
          {
              session.SaveOrUpdate(entity)
              tx.Commit();
          }
          return result;
      }
      session.SaveOrUpdate(entity)
  }
  </code></pre>
  
  <p>The last update throws exception:</p>
  
  <pre><code>StaleObjectStateException was unhandled by user code:
      Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect)
  </code></pre>
  
  <p>SQL query:</p>
  
  <pre><code>UPDATE Forums
  SET    Name = 'Forums Issues (not product support)' /* @p0 */,
         UrlName = 'reportabug' /* @p1 */,
         Description = 'Use this forum to report issues with the online forums application. When reporting an issue please include relevant details such as repro steps, error messages and browser version.' /* @p2 */,
         CategoryId = 'b2cc232c-0d5c-4f35-bb6f-29c67d7d40c2' /* @p3 */,
         TopicsCount = 1 /* @p4 */
  WHERE  ForumId = '864046b7-ca57-48c4-8a81-082103223527' /* @p5 */
  </code></pre>
  
  <p>ForumId is correct.
  Maybe this is concurrency?
  Have any ideas? </p>