org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role
2021-04-02 04:26
标签:配置文件 gem repo throw failed 加载 关联 session style 这个是懒加载异常,就是在查询时没有加载关联表的对象,你读取这个关联对象的时候,hibernate的session已经关闭,所以无法获取对象。 使用事务 org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role 标签:配置文件 gem repo throw failed 加载 关联 session style 原文地址:https://www.cnblogs.com/ukzq/p/12557191.html
可以在配置文件里关闭懒加载 lazily=false @Override
@Transactional
public void run(ApplicationArguments args) throws Exception {
initOrders();
findOrders();
}
@SpringBootApplication
@EnableJpaRepositories
@EnableTransactionManagement
@Slf4j
public class JpaDemoApplication implements ApplicationRunner {
上一篇:PHP易混淆函数的区别及用法汇总(函数和方法的区别)
下一篇:web基础学习心得
文章标题:org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role
文章链接:http://soscw.com/index.php/essay/71238.html