遇到这个问题之前,我去百度和谷歌去搜索了一下。发现各种说法。可是针对我的项目而言,也就是公司的项目而言,这个问题的根源并不是是网上所说的那样。

最后是通过自己的想法做測试得到了解决。

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的更多相关文章

  1. 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 ...

  2. 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 ...

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

    No Hibernate Session bound to thread, and configuration does not allow creat 今天遇到这么一个错误,在网上差了很多都没有能解 ...

  4. 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 ...

  5. 解决No Hibernate Session bound to thread, and configuration does not allow creat。。。

    applicationContext.xml配置 <?xml version="1.0" encoding="UTF-8"?> <beans ...

  6. org.hibernate.HibernateException: No Hibernate Session bound to thread, and configuration does not a

    如果出现了这个错误,看看在使用Hibernate的时候有没有在事务的环境下执行操作!

  7. 出现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 ...

  8. 报错解决:No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here

    大概分析一般使用了注解才会报这方面的错 1.没有在spring的ApplicationContext.xml中开启注解事务 <!-- 开启注解事务 --> <tx:annotatio ...

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

    今天晚上挺悲催的,遇到了这个问题花费我很长时间,现在总结如下: 到这这种情况的发生有两种情况: 1,没有配置事物只要在Spring配置文件中添加如下代码: <bean id="txMa ...

随机推荐

  1. 笔试算法题(28):删除乱序链表中的重复项 & 找出已经排好序的两个数组中的相同项

    出题:给定一个乱序链表,节点值为ASCII字符,但是其中有重复项,要求去除重复项并保证不改变剩余项的原有顺序: 分析:创建一个256(2^8)大小的bool数组,初始化为false,顺序读取链表,将字 ...

  2. nginx网站标准配置

    #nginx开启的进程数worker_processes   4;     #4核CPU   #定义全局错误日志定义类型,[debug|info|notice|warn|crit]error_log  ...

  3. Sax解析xml文档

    测试的xml数据: <?xml version="1.0" encoding="utf-8" ?> <note> <to>G ...

  4. 【Codeforces 444A】DZY Loves Physics

    [链接] 我是链接,点我呀:) [题意] 题意 [题解] 两个点的子图他们的"密度"是比所有联通生成子图都要大的 "只要胆子大,遇到什么问题都不怕!" [代码] ...

  5. 【转】ASP.NET MVC 4 RC的JS/CSS打包压缩功能

    原文链接:http://www.cnblogs.com/shanyou/archive/2012/06/22/2558580.html 打包(Bundling)及压缩(Minification)指的是 ...

  6. bzoj1007 [HNOI2008]水平可见直线 - 几何 - hzwer.com

    Description Input 第一行为N(0 < N < 50000),接下来的N行输入Ai,Bi Output 从小到大输出可见直线的编号,两两中间用空格隔开,最后一个数字后面也必 ...

  7. [K/3Cloud] 隐藏菜单后,如何在插件间接的调用隐藏菜单的操作

    使用场景: 动态表单里面挂了个单据的序时薄,序时薄有菜单,但是把序时薄的工具栏隐藏了.新增,修改全部动态表单自己写.删除和过滤我想间接调用下隐藏的序时薄的删除和过滤按钮的操作.在插件里如何实现? 答: ...

  8. [K/3Cloud] 分录行复制和新增行的冲突如何处理

    新增行:执行AfterCreateNewEntryRow,这个函数里面对一些数据进行处理(比如字段给上默认值): 复制行:复制行过程中希望这些字段能够得到我修改行信息后的数据,如果不处理,执行到Aft ...

  9. POJ3669 Meteor Shower

    http://poj.org/problem?id=3669 类似于迷宫的一道题 但是并没有 给出迷宫具体什么样 但是题目已说在坐标轴的第一象限 然后障碍就是 流星雨所砸范围 安全位置:永远不会发生危 ...

  10. iOS 数据库操作崩溃提示“ int rc = sqlite3_step([_statement statement]);”或者提示“ rc = sqlite3_step(pStmt);”

    数据库崩溃崩溃提示“ int rc = sqlite3_step([_statement statement]);”或者提示“ rc      = sqlite3_step(pStmt);”的时候,可 ...