hibernate 延遲加載問(wèn)題

          If we want the publisher object can be accessed outside the session, there will be two possible
          solutions. One is to initialize the publisher explicitly, we can call the method Hibernate.initialize()
          for this task. This will force the publisher object to be loaded from database.
          Session session = factory.openSession();
          try {
          Book book = (Book) session.get(Book.class, id);
          Hibernate.initialize(book.getPublisher());
          return book;
          } finally {
          session.close();
          }
          Another solution is to turn off the lazy initialization feature for this association. This may decrease
          the performance as the publisher object will be loaded together with the book object every time.
          <hibernate-mapping package="mo.org.cpttm.bookshop">
          <class name="Book" table="BOOK">
          ...
          <many-to-one name="publisher" class="Publisher" column="PUBLISHER_ID"
          lazy="false" />
          </class>
          </hibernate-mapping>

          posted on 2007-07-03 17:23 付軒 閱讀(316) 評(píng)論(0)  編輯  收藏


          只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


          網(wǎng)站導(dǎo)航:
           
          <2007年7月>
          24252627282930
          1234567
          891011121314
          15161718192021
          22232425262728
          2930311234

          導(dǎo)航

          統(tǒng)計(jì)

          常用鏈接

          留言簿(2)

          隨筆檔案

          相冊(cè)

          搜索

          最新評(píng)論

          閱讀排行榜

          評(píng)論排行榜

          主站蜘蛛池模板: 昌都县| 西华县| 南郑县| 台湾省| 安塞县| 新巴尔虎左旗| 石景山区| 安新县| 长海县| 周宁县| 曲靖市| 郁南县| 罗江县| 金阳县| 凌云县| 平邑县| 稷山县| 嘉义市| 湘阴县| 石狮市| 寻乌县| 康马县| 文成县| 辉南县| 稻城县| 闸北区| 龙川县| 临猗县| 襄樊市| 衡阳市| 刚察县| 抚顺市| 绍兴县| 芦溪县| 金乡县| 宜宾市| 南充市| 永仁县| 自治县| 荣成市| 漠河县|