org.hibernate.LazyInitializationException: could not initialize proxy - no Session
程序员文章站
2022-04-17 22:37:47
...
顾名思义,这是一个hibernate懒加载异常:,异常原因是session已经关了,而你还在el表示中调用了懒加载的方法,例如你的el代码:
${car.product.name}//取出购物车商品的名称
其中product是调用Car.getProduct,而getProduct是hibernate的懒加载查询。
解决办法:
1.将orm配置的懒加载改为及时加载。
2.使用联接查询。
3.使用OpenSessionInViewFilter
转载于:https://my.oschina.net/tangzhichao/blog/781568
推荐阅读
-
could not initialize proxy - no Session
-
解决:org.hibernate.LazyInitializationException: could not initialize proxy - no Session
-
HTTP Status 500 - Could not write content: could not initialize proxy - no Session
-
could not initialize proxy - no Session:解决懒加载(排除不需要查询显示的属性)
-
org.hibernate.LazyInitializationException: could not initialize proxy [xxxx] - no Session异常
-
Hiberante异常之org.hibernate.LazyInitializationException: could not initialize proxy - no Session
-
【记录】异常:org.hibernate.LazyInitializationException: could not initialize proxy - no Session
-
org.hibernate.LazyInitializationException: could not initialize proxy 解决方案(JPA)
-
Jpa项目报错:org.hibernate.lazyinitializationexception could not initialize proxy - no session
-
org.hibernate.LazyInitializationException: could not initialize proxy no Session