一、手動加載 如:
          Hibernate.initialize(obj.getUser());//加載用戶對象 



          二、使用OpenSessionInViewFilter 配置解決延遲加載 如:
          <!--OpenSessionInViewFilter 解決延遲加載問題 --> 
          <filter> 
          <filter-name>OpenSessionInViewFilter</filter-name> 
          <filter-class> org.springframework.orm.hibernate3.support.OpenSessionInViewFilter                </filter-class> 
          <!-- singleSession默認為true,若設為false則等于沒用OpenSessionInView --> 
          <init-param> 
          <param-name>singleSession</param-name> 
          <param-value>true</param-value> 
          </init-param> 
          </filter> 
          <filter-mapping> 
          <filter-name>OpenSessionInViewFilter</filter-name> 
          <url-pattern>/*</url-pattern> 
          </filter-mapping> 


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


          網站導航:
           

          posts - 34, comments - 38, trackbacks - 0, articles - 0

          Copyright © 陳小東

          主站蜘蛛池模板: 长武县| 札达县| 龙门县| 顺义区| 长顺县| 长乐市| 文昌市| 盐源县| 讷河市| 苍南县| 东兰县| 金昌市| 大石桥市| 金溪县| 合川市| 荥经县| 开封县| 安康市| 贵南县| 红桥区| 思南县| 易门县| 阿图什市| 墨玉县| 湘潭市| 涟源市| 太湖县| 彩票| 米泉市| 古浪县| 淮滨县| 泾阳县| 上虞市| 开平市| 东乡族自治县| 开封市| 三原县| 股票| 成安县| 鄂尔多斯市| 山丹县|