【记录】异常:org.hibernate.LazyInitializationException: could not initialize proxy - no Session
程序员文章站
2022-04-18 22:05:31
...
【转载自https://blog.csdn.net/u010167086/article/details/17029831】
将hibernate的抓起策略改为join。也就是是left join fetch或inner join fetch语法。就是在<many-to-one../>中配
置lazy="false" fetch="join"即可。
<many-to-one name="paint" class="com.model.Paint" fetch="select">
<column name="paintid" not-null="true" />
</many-to-one>
修改为
<many-to-one name="paint" class="com.model.Paint" lazy="false" fetch="join">
<column name="paintid" not-null="true" />
</many-to-one>
推荐阅读
-
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