title: NHibernate not lazy loading
body: <p>I'm using NHibernate 3.3.3.4001. I'm having an issue where NHibernate is not lazy loading data when issuing a Get request. Instead it is populating the entire object model resulting in very slow performance. The <em>.hbm</em> file is as follows:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" 
                     assembly="My.Assembly" namespace="Assembly.Model"&gt;
  
    &lt;class name="Parent" table="tblParent"&gt;
      &lt;id name="ID"&gt;
          &lt;generator class="native"&gt;&lt;/generator&gt;
      &lt;/id&gt;
      &lt;version name="Version" column="Version"/&gt;    
      &lt;component name="Children"&gt;
        &lt;bag name="Collection" table="tblChildren" 
                               cascade="save-update, merge" inverse="true"&gt;
          &lt;key column="ParentID"&gt;&lt;/key&gt;
          &lt;one-to-many class="Children"&gt;&lt;/one-to-many&gt;
        &lt;/bag&gt;
      &lt;/component&gt;
      &lt;property name="DateCreated" column="DateCreated" update="false" insert="false" /&gt;
      &lt;property name="Inactive" column="Inactive" /&gt;
    &lt;/class&gt;
  
  &lt;/hibernate-mapping&gt;
  </code></pre>
  
  <p>I had expected NHibernate to load all child objects lazily and not send queries to the database. I have tried adding explicit <code>lazy = true</code> and <code>default-lazy=true</code> but it made no difference. I have inspected the <code>Config</code> object and can see that the mappings have <code>islazy=true</code>.</p>
  
  <p>I am calling Get as follows:</p>
  
  <pre><code>using (var transaction = Session.BeginTransaction())
  {
      t = Session.Get&lt;T&gt;(id);
      transaction.Commit();
  }
  </code></pre>
  
  <p>I am puzzled as to why this is not loading lazily but is querying the database for all the child objects?</p>