org.hibernate.HibernateException: No Hibernate Session bound to thread, and configuration does not
遇到这个问题之前,我去百度和谷歌去搜索了一下。发现各种说法。可是针对我的项目而言,也就是公司的项目而言,这个问题的根源并不是是网上所说的那样。
最后是通过自己的想法做測试得到了解决。
1.首先说说我的配置吧。我的配置是通过spring自带的注解来实现 声明式事物管理的。假设我们没去了解spring的声明式事物管理的话,也许我们是得不出什么结论的。
假设你配置过声明式事物管理,你就知道spring是怎么帮你管理的。
2.spring声明式事物管理是在service层管理的,关于到sessionFactory.getCurrentSession()的使用时,是具备有tx(Transactional),全部我们必须在service层中进行@Transactional注解,而不能够再dao层或者其它层进行事物的管理。这也是使用注解方式的声明式事物管理的缺点。
3.spring默认的声明式事物管理的是在service层中(注解方式),假设你採用xml方式进行声明式事物管理的话。能够配置你先要声明式事物管理的形态。
org.hibernate.HibernateException: No Hibernate Session bound to thread, and configuration does not的更多相关文章
- org.hibernate.HibernateException: No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here
org.hibernate.HibernateException: No Hibernate Session bound to thread, and configuration does not a ...
- spring事务管理出错。No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy ...
- No Hibernate Session bound to thread, and configuration does not allow creat
No Hibernate Session bound to thread, and configuration does not allow creat 今天遇到这么一个错误,在网上差了很多都没有能解 ...
- spring 管理事务配置时,结果 报错: No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here这个异常
java.lang.IllegalStateException: No Hibernate Session bound to thread, and configuration does not al ...
- 解决No Hibernate Session bound to thread, and configuration does not allow creat。。。
applicationContext.xml配置 <?xml version="1.0" encoding="UTF-8"?> <beans ...
- org.hibernate.HibernateException: No Hibernate Session bound to thread, and configuration does not a
如果出现了这个错误,看看在使用Hibernate的时候有没有在事务的环境下执行操作!
- 出现No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here异常
问题描述: public void save(BaseEntity baseEntity) { Session session = null; try { session = currentSessi ...
- 报错解决:No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here
大概分析一般使用了注解才会报这方面的错 1.没有在spring的ApplicationContext.xml中开启注解事务 <!-- 开启注解事务 --> <tx:annotatio ...
- No Hibernate Session bound to thread, and configuration does not allow
今天晚上挺悲催的,遇到了这个问题花费我很长时间,现在总结如下: 到这这种情况的发生有两种情况: 1,没有配置事物只要在Spring配置文件中添加如下代码: <bean id="txMa ...
随机推荐
- java_线程分类
线程分为守护线程和用户线程,如java虚拟机的回收机制就是守护线程,线程开始运行它就启动,线程结束它就结束 用户线程变守护线程:Thread(线程).setDaemon(true)
- EasyUI入门,DataGrid(数据表格)
搭建EasyUI 1.进入官网,下载EasyUI的程序包.地址:http://www.jeasyui.com/download/list.php 2.先导入css样式,引入程序包 3.进入EasyUI ...
- SQL Server中 sysobjects、sysolumns、systypes
1.sysobjects 系统对象表. 保存当前数据库的对象,如约束.默认值.日志.规则.存储过程等 在大多数情况下,对你最有用的两个列是Sysobjects.name和Sysobjects.x ...
- 机器翻译注意力机制及其PyTorch实现
前面阐述注意力理论知识,后面简单描述PyTorch利用注意力实现机器翻译 Effective Approaches to Attention-based Neural Machine Translat ...
- org.dom4j.DocumentException
在使用soapui测试webservice接口的时候如果需要传入xml格式的参数 这么写是不对的,会报错org.dom4j.DocumentException: Error on line 1 of ...
- uLua-案例学习-API
LuaState.Start()初始化吧 LuaState.AddSearchPath(string fullPath)增加搜索路径,这样在执行lua文件时就不需要输入全路径,类似环境变量path. ...
- 利用类装饰器自定制property实现延迟计算
class LazyProperty: ''' hello,我是非数据描述符(没有定义__set__,不然是大哥数据描述符了--!) ''' def __init__(self, func): pri ...
- python Django 相关学习笔记
Django框架 pip3 install django 命令: # 创建Django程序 django-admin startproject mysite # 进入程序目录 cd mysite # ...
- SQLAlchmy模块详解
之前写过一篇博客介绍过sqlalchemy的基本用法,本篇博客主要介绍除增删改查以外SQLAlchemy对数据库表的操作,主要内容有单表操作.一对多操作.多对多操作. 一.单表操作 单表操作的增删改查 ...
- UI & 原型
UI & 原型 产品原型设计与团队实时协作平台 https://www.xiaopiu.com/download https://www.xiaopiu.com/forum/posts/5b9 ...