No value for key SessionFactoryImpl

No value for key [org.hibernate.internal.SessionFactoryImpl@549efabc] bound to thread [http-nio-8080-exec-1]

造成这个问题直接原因是由于 SessionFactoryImpl 没有currentSession 这个属性或方法调用

 

问题最终原因spring 的orm框架中的 LocalSessionFactoryBean 和 HibernateTransactionManager 两个类版本不一致造成的

由于我用的一个是hibernate4 一个是hibernate5,所以当我把LocalSessionFactoryBean 的导入改成hiberante5就行了

import org.springframework.orm.hibernate4.LocalSessionFactoryBean;
import org.springframework.orm.hibernate5.HibernateTransactionManager;

改为
import org.springframework.orm.hibernate5.LocalSessionFactoryBean;
import org.springframework.orm.hibernate5.HibernateTransactionManager;
posted on 2017-02-10 10:41  码农时刻  阅读(1179)  评论(0编辑  收藏  举报