title: Does NHibernate update version on select?
body: <p>I have a very simple mapping like: </p>
  
  <pre><code>public abstract class EntityMap&lt;TEnt, TId, TDto&gt; : ClassMap&lt;TEnt&gt;
      where TEnt: Entity&lt;TId, TDto&gt; 
      where TDto : DataTransferObject&lt;TDto, TId&gt;
  {
      protected EntityMap()
      {
          Id(x =&gt; x.Id).GeneratedBy.GuidComb();
          Map(x =&gt; x.Name).Not.Nullable().Unique().Length(255);
          Version(x =&gt; x.Version);
          SelectBeforeUpdate();
      } 
  </code></pre>
  
  <p>I use this mapping to perform a test like:</p>
  
  <pre><code>    [TestMethod]
      public void ThatVersionDoesNotChangedAfterOnlyAReadAction()
      {
          var services = BrandServices.WithDto(BrandTestFixtures.GetDto()).Get();
          Assert.AreEqual(1, services.Version);
          Context.CurrentSession().Transaction.Commit();
          Context.CurrentSession().Transaction.Begin();
          var brand = BrandServices.Brands.Single(x =&gt; x.Name == BrandTestFixtures.GetDto().Name);
          Assert.AreEqual(1, brand.Version);
      }
  </code></pre>
  
  <p>So, in this test I create an object mapped to the entity map and this object is inserted into the database. Semantically, there should only be 1 version of the object. However, what happens is that upon commit the inserted object is immediately updated with a new version. Moreover, when I retrieve the object again to check the version, the version is incremented again. The expected version should be 1, the version of the test brand is 3 but in the database the version is 4!?!?!</p>
  
  <p>I tried various flavors of mapping options. The most puzzling part to me is that version is incremented at the moment the object is retrieved from the database. In my full application with multiple bidirectional relations this leads to severe problems. Is there a way to modify this behavior, or do I have to resort to a home made versioning mechanism?</p>
  
  <pre><code>-- statement #1
  select brand0_.Id      as Id0_,
         brand0_.Version as Version0_,
         brand0_.Name    as Name0_
  from   [Brand] brand0_
  
  -- statement #2
  select brand0_.Id      as Id0_,
         brand0_.Version as Version0_,
         brand0_.Name    as Name0_
  from   [Brand] brand0_
  
  -- statement #3
  INSERT INTO [Brand]
             (Version,
              Name,
              Id)
  VALUES     (1 /* @p0_0 */,
              'Dynatra' /* @p1_0 */,
              '8ca15020-2e23-4ace-adff-9f4800b706d5' /* @p2_0 */)
  
  -- statement #4
  UPDATE [Brand]
  SET    Version = 2 /* @p0 */,
         Name = 'Dynatra' /* @p1 */
  WHERE  Id = '8ca15020-2e23-4ace-adff-9f4800b706d5' /* @p2 */
         AND Version = 1 /* @p3 */
  
  -- statement #5
  commit transaction
  
  -- statement #6
  begin transaction with isolation level: Unspecified
  
  -- statement #7
  UPDATE [Brand]
  SET    Version = 3 /* @p0 */,
         Name = 'Dynatra' /* @p1 */
  WHERE  Id = '8ca15020-2e23-4ace-adff-9f4800b706d5' /* @p2 */
         AND Version = 2 /* @p3 */
  
  -- statement #8
  select brand0_.Id      as Id0_,
         brand0_.Version as Version0_,
         brand0_.Name    as Name0_
  from   [Brand] brand0_
  
  -- statement #9
  UPDATE [Brand]
  SET    Version = 4 /* @p0 */,
         Name = 'Dynatra' /* @p1 */
  WHERE  Id = '8ca15020-2e23-4ace-adff-9f4800b706d5' /* @p2 */
         AND Version = 3 /* @p3 */
  </code></pre>