硬盤的BLOG

          引導分區(qū)

          JPA(Hibernate)+Spring+Struts2 中延遲加載的解決辦法

          在entity中的@OneToMany、@OneToOne等中設置fetch = FetchType.LAZY時,在Struts2的Action中進行相關操作出現(xiàn)錯誤信息如下
          org.hibernate.LazyInitializationException: could not initialize proxy no session

          解決方法:
          在web.xml中加入
          ??<filter>
          ????
          <filter-name>SpringOpenEntityManagerInViewFilter</filter-name>
          ????
          <filter-class>org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter</filter-class>
          ??
          </filter>
          ??
          <filter-mapping>
          ????
          <filter-name>SpringOpenEntityManagerInViewFilter</filter-name>
          ????
          <url-pattern>*.action</url-pattern>
          ??
          </filter-mapping>

          更多其它時刻解決延遲加載錯誤的方法參見 http://www.javaeye.com/topic/129698

          posted on 2008-07-25 23:45 我是一塊硬盤 閱讀(623) 評論(0)  編輯  收藏 所屬分類: JPA


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


          網站導航:
           
          主站蜘蛛池模板: 灵川县| 富蕴县| 海伦市| 丹江口市| 阆中市| 临漳县| 仲巴县| 县级市| 天门市| 博乐市| 陆丰市| 盐池县| 晋州市| 江山市| 唐河县| 内江市| 兴义市| 水城县| 德庆县| 什邡市| 红桥区| 台东县| 思茅市| 仁布县| 云安县| 辽宁省| 鞍山市| 集贤县| 张家口市| 岚皋县| 东源县| 辽宁省| 太康县| 延吉市| 陇川县| 峨边| 钟祥市| 凯里市| 门源| 宝清县| 松滋市|