当 Hibernate 和 Spring 整合时,在 Spring 中指定的 Hibernate.cfg.xml 文件内容中要注释掉以下内容:

<!-- Enable Hibernate's automatic session context management -->
<!-- <property name="current_session_context_class">thread</property> -->
这样,才能将 Hibernate 的 session 交给 Spring 来管理,而 Spring 才能使用切面方法,对 DAO 中的方法进行管理。 在配置文件中注释掉<property name="current_session_context_class">thread</property>后解决

Hibernate 与Spring整合出现 hibernate.HibernateException: createCriteria is not valid without active transaction的更多相关文章

  1. spring整合hibernate的时候报异常org.hibernate.HibernateException: createQuery is not valid without active transaction

    在整合Spring4+hibernate4时候,当代码执行到dao中CRUD操作时,报了一个异常, org.hibernate.HibernateException: createQuery is n ...

  2. Exception in thread "main" org.hibernate.HibernateException: save is not valid without active transaction

    在spring4+hibernate4整合过程中,使用@Transactional注解事务会报"Exception in thread "main" org.hibern ...

  3. org.hibernate.HibernateException: getFlushMode is not valid without active transaction

    Spring & Hibernate 整合异常记录: org.hibernate.HibernateException: getFlushMode is not valid without a ...

  4. 异常:getHibernateFlushMode is not valid without active transaction; nested exception is org.hibernate.HibernateException: getHibernateFlushMode is not valid without active transaction getHibernateFlu

    场景: 在使用spring整合hibernate调用的HibernateTemplate时报错解决: 在spring配置文件中添加事务的配置 <bean id="hibernateTr ...

  5. Exceprtion:e createQuery is not valid without active transaction; nested exception is org.hibernate.HibernateException: createQuery is not valid without active transaction

    如果增加配置了current_session_context_class属性,查询的时候需要session.beginTrasaction()来开启事务

  6. ssh整合之三hibernate和spring整合

    1.拷贝我们的spring事务控制所需的jar包 2.在spring容器中配置我们的hibernateTemplate以及事务管理器 <?xml version="1.0" ...

  7. spring中使用Hibernate中的getCurrentSession报出:createQuery is not valid without active transaction

    1.错误信息 HTTP Status 500 - createQuery is not valid without active transaction type Exception report m ...

  8. struts2,hibernate,spring整合笔记(3)

    struts2,hibernate,spring整合笔记(1) struts2,hibernate,spring整合笔记(2) 配好struts和hibernate就要开始spring了 老规矩,还是 ...

  9. struts2,hibernate,spring整合笔记(2)

    上一话struts2,hibernate,spring整合笔记(1) 接下来继续 配置完struts之后就要开始hibernate的配置 hibernate的环境并不依赖web开发环境,在我第一次配置 ...

随机推荐

  1. intellj idea点击导航栏打开的一个类,怎么才能定位到类的目录

  2. 【NOI】2004 郁闷的出纳员

    [算法]平衡树(treap) [题解] treap知识见数据结构. 解法,具体细节见程序. #include<cstdio> #include<algorithm> #incl ...

  3. 边缘检测:Canny算子,Sobel算子,Laplace算子

    1.canny算子 Canny边缘检测算子是John F.Canny于 1986 年开发出来的一个多级边缘检测算法.更为重要的是 Canny 创立了边缘检测计算理论(Computational the ...

  4. 头像截取 图片上传 js插件

    先看一下整体效果 页面html <div class="row"> <div class="tabs-container"> <u ...

  5. 关于Solaris系统“mpt_sas”驱动

    1.mpt_sas 驱动源文件所在系统源代码中目录: illumos-soulos/usr/src/uts/common/sys/scsi/adapters/mpt_sas  -- 头文件 illum ...

  6. python基础===getattr()函数使用方法

    getattr(object, name[,default]) 获取对象object的属性或者方法,如果存在打印出来,如果不存在,打印出默认值,默认值可选.需要注意的是,如果是返回的对象的方法,返回的 ...

  7. Chrome控制台的妙用之使用XPATH

    谷歌浏览器,对于作为程序员的我们来说可以是居家必备了,应该用的相当的熟悉了,我们用的最多的应该是network选项吧,一般用来分析网页加载的请求信息,比如post参数之类的,这些基本的功能基本上够用了 ...

  8. mac cocoapod安装过程

    cocoapod: 自动化管理第三方开发包的一个插件, 废话不多说, 一个新手只需做如下几个步骤 1-> 安装ruby环境(可忽略, 不是必要) 1.1 首先我们先看看当前你机器上ruby的版本 ...

  9. c json实战引擎五 , 优化重构

    引言 scjson是一个小巧的纯c跨平台小巧引擎. 适用于替换老的cJSON引擎的场景. 数据结构和代码布局做了大量改进.优势体现在以下几个方面: 1) 跨平台 (window 10 + VS2017 ...

  10. ACE_INET_Addr类 API

    ACE_INET_Addr类,在这个ACE_网络框架中,应该是比较重要的辅助类,该类主要封装了C SOCKET 的地址对象,通过外观封装的模式,把struct sockaddr_in封装在内.方便用户 ...