blogjava's web log

          blogjava's web log
          ...

          NHibernate "Failed to lazily initialize a collection"

          				
          						
          "Failed to lazily initialize a collection"
          				try
          {
          session = Class1.GetFactory().OpenSession();
          Archives archives= session.Get(typeof(Archives), id) as Archives;
          NHibernate.NHibernateUtil.Initialize(archives.ArticlesList);return archives;
          }
          catch (Exception ex)
          {
          throw ex;
          }
          finally { session.Close(); }
          ?或者
          session.CreateCriteria(typeof(Catalog))
          .Add(Expression.Eq("ID"),id)
          .SetFetchMode("Specifications",FetchMode.Join)
          .UniqueResult() as Catalog;


          或者

          left JOIN FETCH

          這樣在session關閉 照樣取他的 級聯對象 ,

          posted on 2007-06-15 22:23 record java and net 閱讀(1516) 評論(0)  編輯  收藏


          只有注冊用戶登錄后才能發表評論。


          網站導航:
           

          導航

          常用鏈接

          留言簿(44)

          新聞檔案

          2.動態語言

          3.工具箱

          9.文檔教程

          友情鏈接

          搜索

          最新評論

          主站蜘蛛池模板: 台州市| 龙州县| 文昌市| 鹤庆县| 思南县| 繁昌县| 西盟| 高邮市| 巴楚县| 清河县| 尤溪县| 甘孜县| 偏关县| 密山市| 安宁市| 黄陵县| 乐东| 萝北县| 汾阳市| 北川| 巴楚县| 保山市| 盐津县| 伊吾县| 盐池县| 四川省| 广东省| 巴林左旗| 资讯 | 安溪县| 墨竹工卡县| 若羌县| 泸西县| 合肥市| 天祝| 万年县| 张掖市| 额尔古纳市| 乡城县| 墨江| 长海县|