您的位置:首页 > 其它

No Hibernate Session bound to thread, and configuration does not allow

2014-11-24 22:27 477 查看
今天晚上挺悲催的,遇到了这个问题花费我很长时间,现在总结如下:

到这这种情况的发生有两种情况:

1,没有配置事物只要在Spring配置文件中添加如下代码:

<bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">

<property
name="sessionFactory" ref="sessionFactory"/>

</bean>

<tx:annotation-driven
transaction-manager="txManager"/>

然后在DAO程序前面加上@Transactional即可。

2,连接数据的配置是否正确,如果连接字符串不正确的话,就不能够创建SessionFactory,也就无从谈起事务了。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐