no currentsessioncontext configured!
使用hibernate框架报错
配置了session工厂类,使用getCurrentSession();时候引起的,原因是currentSession配置错误

当我们使用currentSession的时候需要在hibernate.cfg.xml中进行如下事务配置:

  1、如果是本地事务:

    <property name="hibernate.current_session_context_class">thread</property>

  2、如果是全局事务

  <property name="hibernate.current_session_context_class">jta</property>

如果获得session 对象使用 sessionFactory.openSession()就不会出现这个错误了。

openSession()是不管任何情况都重新开启一个Session,而getCurrentSession();相对的增加了一个判断,在有Session的情况下就会直接去调用,没有session的话才会创建,如果有事务操作的话getCurrentSession();更好一些,很容易的使得一个线程只有一个session对象。

报错 no currentsessioncontext configured!的更多相关文章

  1. pycurl mac 安装报错Curl is configured to use SSL,

    1.使用安装第三方插件的方式安装pycurl:pip3 install pycurl 报错提示如下: Curl is configured to use SSL, but we have not be ...

  2. 使用Quartz任务调用的时候报错Based on configured schedule, the given trigger will never fire.

    org.quartz.SchedulerException: Based on configured schedule, the given trigger will never fire. 大概意思 ...

  3. 【已解决】将jsp文件在浏览器打开直接出现代码,在浏览器出现本地地址,tomcat报错

    问题背景: 导入了一个项目直接打开可以,但是想跟一遍代码,把配置文件全部整理成为一个springmvc的基础配置文件 跟着配置到自己tomcat就不管怎样都是下面的截图  希望可以帮到一起报错的朋友快 ...

  4. hibernate报错org.hibernate.HibernateException: No CurrentSessionContext configured!

    org.hibernate.HibernateException: No CurrentSessionContext configured! at org.hibernate.internal.Ses ...

  5. .NET CORE 使用Session报错:Session has not been configured for this application or request

    报错信息:Session has not been configured for this application or request 解决方案:在Startup.cs文件中的Configure方法 ...

  6. gitkraken clone报错 Configured SSH key is invalid

    gitkraken clone远程仓库时报错 Configured SSH key is invalid. Please confirm that is properly associated wit ...

  7. laravel 项目表单中有csrf_token,但一直报错419错误 解决redis连接错误:MISCONF Redis is configured to save RDB snapshots, but it is currently not able to persi

    laravel 项目表单中有csrf_token,但一直报错419错误,因为项目中使用到Redis缓存,在强制关闭Redis后出现的问题,查询laravel.log文件查找相关问题 安装redis后在 ...

  8. django中执行py报错Requested setting DEFAULT_INDEX_TABLESPACE, but settings are not configured

    https://blog.csdn.net/heybob/article/details/49684261 django代码下面直接run的时候报错: django.core.exceptions.I ...

  9. django调用py报错 django.core.exceptions.ImproperlyConfigured: Requested setting DEFAULT_INDEX_TABLESPACE, but settings are not configured.

    完整报错信息如下 django.core.exceptions.ImproperlyConfigured: Requested setting DEFAULT_INDEX_TABLESPACE, bu ...

  10. eclipse egit 报错 The current branch is not configured for pull No value for key branch.master

    eclipse egit 插件 pull报错 The current branch is not configured for pull No value for key branch.master ...

随机推荐

  1. odoo 开发入门教程系列-继承(Inheritance)

    继承(Inheritance) Odoo的一个强大方面是它的模块化.模块专用于业务需求,但模块也可以相互交互.这对于扩展现有模块的功能非常有用.例如,在我们的房地产场景中,我们希望在常规用户视图中直接 ...

  2. 创建SpringBoot项目,在yml中配置数据库, driver-class-name: com.mysql.cj.jdbc.Driver标红报错解决方式

    一.报错原因 com.mysql.cj.jdbc.Driver一直标红报错,原因在于pom.xml中mysql包没有下载下来,或者在创建项目的时候有问题 二.解决方案 在pom.xml添加 <d ...

  3. Docker入门实践笔记-Dockerfile

    镜像是一个打包文件,其中包含了应用程序及其运行所依赖的环境,例如文件系统.环境变量.配置参数等等 联合文件系统 容器镜像内部并不是一个平坦的结构,而是由许多的镜像层组成,每层都是只读不可修改修改的一组 ...

  4. If选择语句的用法

    今天我们学习下If判断语句. 首先了解下它有几种用法: If单选择语句 If双选择语句 If多选择语句 我们一个一个用,每一个用法都给一个运用的过程演练一下. If单选择语句:我们很多需要判断一个东西 ...

  5. 重复delete 对象指针后的 异常调用栈怪异 解析

    Release版VC6 MFC程序 程序正常退出时得到一个如下异常调用栈: 0:000> kb # ChildEBP RetAddr Args to Child WARNING: Frame I ...

  6. 获取电脑的网络连接状态(四)IPHost

    网络连接判断,使用IPHost测试获取: 1 public static bool IsIPHostConnected() 2 { 3 try 4 { 5 System.Net.IPHostEntry ...

  7. fiddler简单使用

    fiddler简单使用 下载 网上找资源下载 安装 一路同意就可以了 使用 1.配置https证书 这些项全选,然后信任证书,就可以抓到ssl的包 2.改变网络端口 3.改写网页代码 以爬虫网为例,先 ...

  8. 2022-12-19:大的国家。如果一个国家满足下述两个条件之一,则认为该国是 大国 : 面积至少为 300 万平方公里(即,3000000 km2),或者 人口至少为 2500 万(即 250000

    2022-12-19:大的国家.如果一个国家满足下述两个条件之一,则认为该国是 大国 : 面积至少为 300 万平方公里(即,3000000 km2),或者 人口至少为 2500 万(即 250000 ...

  9. 2022-07-08:以下go语言代码输出什么?A:3;B:+Inf;C:true;D:编译错误。 package main import “fmt“ func main() { var

    2022-07-08:以下go语言代码输出什么?A:3:B:+Inf:C:true:D:编译错误. package main import "fmt" func main() { ...

  10. 2021-04-15:给定一个由字符串组成的数组strs,必须把所有的字符串拼接起来,返回所有可能的拼接结果中,字典序最小的结果。

    2021-04-15:给定一个由字符串组成的数组strs,必须把所有的字符串拼接起来,返回所有可能的拼接结果中,字典序最小的结果. 福大大 答案2021-04-15: "b"和&q ...