java - springboot 整合hibernate 如何处理延迟加载问题
本文介绍了java - springboot 整合hibernate 如何处理延迟加载问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问 题
springboot 整合hibernate 如何处理延迟加载问题
解决方案
你使用Spring Boot但是没有使用Spring JPA?而是自己整合的Hibernate?
那么或许你可以尝试添加添加OpenSessionInViewInterceptor即可。
@SpringBootApplication
public class WebsiteApplication {
public static void main(String[] args) {
SpringApplication.run(WebsiteApplication.class, args);
}
@Bean
public OpenSessionInViewInterceptor openSessionInViewInterceptor() {
OpenSessionInViewInterceptor interceptor = new OpenSessionInViewInterceptor();
interceptor.setSessionFactory(sessionFactory());
return interceptor;
}
}
这篇关于java - springboot 整合hibernate 如何处理延迟加载问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文