一个类实现了InitializingBean后,在afterPropertiesSet方法里取sessionFactory.getCurrentSession();,但是报异常 No Session found for current thread。说明spring的事务没有开启,但是已经配置了。想请教下各位大大是怎么回事
sessionFactory.getCurrentSession方法不能在此处调用
这个session是hibernate的session吧?
另外sessionFactory.getCurrentSession 如果没有session会帮你创建一个新的session