SpringBoot JPA 错误:org.hibernate.lazyinitializationexception could not initialize proxy - no session
程序员文章站
2022-03-02 14:13:55
...
在练习OneToMany
时发生错误:
org.hibernate.lazyinitializationexception could not initialize proxy - no session
异常原因:jpa
或hibernate
的延迟加载,这里的话参考链接,在spring boot
的配置文件application.properties
添加
spring.jpa.properties.hibernate.enable_lazy_load_no_trans=true
添加以后又出现问题:
java.lang.*Error
参考链接,这是因为Lombok
自动生产了hashCode
和 toString
在两个表互相引用时会产生死循环
,把实体类的@Data
注解换成@Getter
和@Setter
即可。
上一篇: 统计每个字符串出现的次数
推荐阅读
-
解决:org.hibernate.LazyInitializationException: 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
-
jpa 解决org.hibernate.LazyInitializationException: could not initialize proxy - no Session
-
Spring DATA JPA org.hibernate.LazyInitializationException: could not initialize proxy - no Session
-
org.hibernate.LazyInitializationException: could not initialize proxy - no Session