Strange lazy load problem

Posted by JooLio on Stack Overflow See other posts from Stack Overflow or by JooLio
Published on 2010-12-25T15:45:46Z Indexed on 2010/12/25 15:54 UTC
Read the original article Hit count: 145

Filed under:
|
public class QuickQuoteTemplate
{
    ...
    public virtual IList<QuickQuoteTemplateItem> InnerItems
    {
        get; 
        set;
    }
    ...
}

public class QuickQuoteTemplateItem
{
    ...
    public virtual IList<QuickQuoteTemplateItem> InnerItems
    {
        get;
        set;
    }
    ...
}

<class name="QuickQuoteTemplate" table="SA_QUICK_QUOTE_TEMPLATE">
  ...
  <bag name="InnerItems" lazy="false" inverse="true" cascade="delete" >
      <key column="PARENT_QQ_TEMPLATE_ID" ></key>
      <one-to-many class="QuickQuoteTemplateItem" />
  </bag>
  ...
</class>

<class name="QuickQuoteTemplateItem" table="SA_QUICK_QUOTE_TEMPLATE_ITEMS">
    ...
    <bag name="InnerItems" lazy="false" inverse="false" cascade="delete">
        <key column="PARENT_ITEM_ID" />
        <one-to-many class="QuickQuoteTemplateItem" />
    </bag>
    ...
</class>

InnerItems collections is set as no lazy, but after disposing the ISession instance, quickQuote.InnerItems is crying "failed to lazily initialize a collection, no session or session was closed".
I've even tried to call InnerItems before the session is closed by myself. It successfully retrieves, but after disposing of the session it becomes not initialized.

© Stack Overflow or respective owner

Related posts about nhibernate

Related posts about hibernate