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. Linux Socket网络编程: TCP/UDP与本地套接字

    网络交互和数据传输好比打电话,socket就像电话机,是在网络编程世界中与外界进行网络通信的途径 TCP网络编程 基于服务器-客户端模型,使用套接字完成连接的建立 服务端准备连接 使用socket创建 ...

  2. rails的接口查询详解

    Retrieving Objects from the Database find "find"是一种常用的数据库查询方法,在Rails中被用于从数据库中查找单个记录.它可以接收一 ...

  3. TypeScript 学习笔记 — 数组常见的类型转换操作记录(十四)

    获取长度 length type LengthOfTuple<T extends any[]> = T["length"]; type A = LengthOfTupl ...

  4. 笔记六:进程间的通信(IPC通信之消息队列)

    IPC通信之消息队列 "消息"是在两台计算机间传送的数据单位.消息可以非常简单,例如只包含文本字符串:也可以更复杂,可能包含嵌入对象 .消息被发送到队列中."消息队列&q ...

  5. JavaFx 实现水平滚动文本(跑马灯效果)

    原文地址: JavaFx 实现水平滚动文本(跑马灯效果) - Stars-One的杂货小窝 本文是以TornadoFx框架进行编写,各位使用JavaFx可以参考 代码已经封装在common-contr ...

  6. 用C#发送post请求,实现更改B站直播间标题[简单随笔]

    第一次发这样的网络数据包.记录一下. API参考 https://github.com/SocialSisterYi/bilibili-API-collect/blob/master/live/man ...

  7. Python-获取Local Storage和Session Storage

    一.简介 LocalStorage 是只读的.数据存储也是跨浏览器会话.LocalStorage 类似于SessionStorage. 区别在于,数据存储在 LocalStorage 是无期限的,而当 ...

  8. abp(net core)+easyui+efcore实现仓储管理系统——供应商管理升级之上(六十三)

    abp(net core)+easyui+efcore实现仓储管理系统目录 abp(net core)+easyui+efcore实现仓储管理系统--ABP总体介绍(一) abp(net core)+ ...

  9. 当Serverless遇到Regionless:现状与挑战

    摘要:本文尝试基于分析现有的学术文章,剖析Serverless与Regionless并存时,在性能提升和成本控制两个方向的现状与挑战 本文分享自华为云社区<当Serverless遇到Region ...

  10. Hibernate 基本操作、懒加载以及缓存

    前言 上一篇咱们介绍了 Hibernate 以及写了一个 Hibernate 的工具类,快速入门体验了一波 Hibernate 的使用,我们只需通过 Session 对象就能实现数据库的操作了. 现在 ...