title: NHibernate second level cache caching entities with no caching configuration
body: <p>I have configured second level cache on the session factory. However for the POCO entity I have not enabled caching.</p>
  
  <p>I am using Fluent NHibernate for configuring the SessionFactory and the POCO entities.</p>
  
  <p>Here is the configuration of the session factory:</p>
  
  <pre><code>            var cfg = Fluently.Configure()
              .Database(MsSqlConfiguration.MsSql2008.ConnectionString(connectionString)
                            .Provider("NHibernate.Connection.DriverConnectionProvider, NHibernate")
                            .Dialect&lt;CustomMsSql2008Dialect&gt;()
                            .Driver&lt;SqlAzureClientDriver&gt;()
                            .ShowSql())
              .Cache(x =&gt;
                  {
                      x.UseQueryCache();
                      x.UseSecondLevelCache().ProviderClass&lt;HashtableCacheProvider&gt;().UseMinimalPuts();
                  })
  </code></pre>
  
  <p>The POCO entity configuration is as follows:</p>
  
  <pre><code>        public CustomerConfiguration()
      {
          Table("Sys_Customer");
          DynamicUpdate();
  
          Id(x =&gt; x.Id).GeneratedBy.GuidComb().UnsavedValue(Guid.Empty);
  
          Map(x =&gt; x.Code);
          Map(x =&gt; x.Name);
          Map(x =&gt; x.IsActive);
          Component(x =&gt; x.Contact).ColumnPrefix("Contact_");
          Component(x =&gt; x.Address).ColumnPrefix("Address_");
          Map(x =&gt; x.IsDeleted);
          Map(x =&gt; x.CreatedOn).Column("CreatedOn");
          Map(x =&gt; x.CreatedBy).Column("CreatedBy").Length(100);
          Map(x =&gt; x.LastModifiedOn).Column("LastModifiedOn");
          Map(x =&gt; x.LastModifiedBy).Column("LastModifiedBy").Length(100);
  
          Version(x =&gt; x.RowVersion).UnsavedValue("0");
      }
  </code></pre>
  
  <p>So clearly for the Sys_Customer entity i have not configured any Caching, yet when i run the following code: the database is hit only once:</p>
  
  <pre><code>        using (ISession s = RepositorySession)
          {
              var f = s.Get&lt;Customer&gt;(new Guid("75EDC0C2-4E58-43FF-B0D8-8C52FBB2D502"));
              var d = f.Code;
          }
  
          using (ISession s = RepositorySession)
          {
              var f = s.Get&lt;Customer&gt;(new Guid("75EDC0C2-4E58-43FF-B0D8-8C52FBB2D502"));
              var d = f.Code;
          }
  </code></pre>
  
  <p>when I remove the Cache Configuration from the SessionFactory then the database is hit twice. so clearly the entity is getting cached in the second level cache. </p>
  
  <p>Can someone tell me how to avoid caching the entity into the second level cache of NHibernate????</p>