最近用springboot,spring-boot-starter-data-jpa(jpa包含了hibernate)配置一个框架遇到很多问题:
1,错误:
Could not obtain transaction-synchronized Session for current thread
解决方法:
在DAO实现层添加:
@Transactional @EnableTransactionManagement sessionFactory.getCurrentSession();//必须在这类中加上特性标签 @Transactional @EnableTransactionManagement
参考别人的:Spring Hibernate - Could not obtain transaction-synchronized Session for current thread - Stack Overflow
2,错误:
org.springframework.orm.hibernate5. HibernateSystemException: Could not obtain transaction-synchronized Session for current thread; nested exception is org.hibernate.HibernateException:
解决方法(jpa和):
在application.properties文件添加:
spring.jpa.open-in-view=false
参考别人:java - ClassCastException: org.springframework.orm.jpa.EntityManagerHolder cannot be cast to org.springframework.orm.hibernate5.SessionHolder - Stack Overflow
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)