JPA(Hibernate)+Spring+Struts2 中延迟加载的解决办法

阅读更多

在entity中的@OneToMany、@OneToOne等中设置fetch = FetchType.LAZY时,在Struts2的Action中进行相关操作出现错误信息如下
org.hibernate.LazyInitializationException: could not initialize proxy no session

解决方法:
在web.xml中加入

  
    SpringOpenEntityManagerInViewFilter
    org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter
  
  
    SpringOpenEntityManagerInViewFilter
    *.action
  

更多其它时刻解决延迟加载错误的方法参见 http://www.iteye.com/topic/129698

你可能感兴趣的:(JPA,Hibernate,Spring,ORM,Web)