title: Nhibernate LazyInitializationException after Session.Clear
body: <p>In my application before every query I want to do the following</p>
  
  <pre><code>public List&lt;Supplier&gt; GetAllSuppliers()
  {
          NHibernateHelper.Session.Clear();
  
          string query = "from Supplier order by FirstName, LastName asc ";
  
          var result = NHibernateHelper.Session.CreateQuery(query).List&lt;Supplier&gt;();
  
          return (List&lt;Supplier&gt;)result ?? new List&lt;Supplier&gt;();
  }
  </code></pre>
  
  <p>The following code line is meant to clear the session so when I query all my suppliers I want to have the whole list again from the database and not from the cache. Because NHibernate remembers that object or something like that and does not receive the changes that are made in the database (my application is used on multiple computers, that's the main reason I want to get the "live" data)</p>
  
  <pre><code>NHibernateHelper.Session.Clear();
  </code></pre>
  
  <p>But my Supplier object has an Address object which is being lazy loaded. In my list I     select that Supplier object and it shows it's name and also the address. And that's when the errors occurs:</p>
  
  <pre><code>An unhandled exception of type 'System.Windows.Markup.XamlParseException' occurred in PresentationFramework.dll
  
  Additional information: Initializing[Model.Supplier#1]-Could not initialize proxy - no Session.
  </code></pre>
  
  <p>And if set that line of code in comments It works...But I don't want that behaviour that it uses the cache...</p>
  
  <p>Mapping for Supplier</p>
  
  <pre><code>    public SupplierMap()
      {
          Id(x =&gt; x.Id);
          Map(x =&gt; x.Name);
          Map(x =&gt; x.Btw);
          Map(x =&gt; x.Email);
          Map(x =&gt; x.Fax);
          Map(x =&gt; x.Telephone);           
  
          References(x =&gt; x.Address).Cascade.All();
  
          HasMany(x =&gt; x.Articles);
  
          Table("tbl_suppliers");
      }
  </code></pre>
  
  <p>Mapping for address</p>
  
  <pre><code>    public AddressMap()
      {
          Id(x =&gt; x.Id);
          Map(x =&gt; x.Street).Length(10000);
          Map(x =&gt; x.Number).Length(10000);
          Map(x =&gt; x.Zip).Length(10000);
          Map(x =&gt; x.City).Length(10000);
          Map(x =&gt; x.Country).Length(10000);
  
          Table("tbl_addresses");
      }
  </code></pre>
  
  <p>Any ideas on this issue?</p>
  
  <p><strong>EDIT</strong>
  I've found following link: <a href="https://nhibernate.jira.com/browse/NH-2791" rel="nofollow">https://nhibernate.jira.com/browse/NH-2791</a>
  Seems like the same problem but with no solution...</p>