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. 【前端基础】(一)Es6新特性

    1 Es6 全称为ECMAScript是浏览器脚本语言的规范,而各种我们熟知的js语言则是规范的具体体现. 1.1 Es6新特性 ① let与var 作用域 <script> { var ...

  2. 从原理聊JVM(一):染色标记和垃圾回收算法

    作者:京东科技 康志兴 1 JVM运行时内存划分 1.1 运行时数据区域 • 方法区 属于共享内存区域,存储已被虚拟机加载的类信息.常量.静态变量.即时编译器编译后的代码等数据.运行时常量池,属于方法 ...

  3. ROS机器人摄像头寻线

    ROS机器人摄像头寻线 连接小车 注意:必须在同一区域网 ssh clbrobort@clbrobort 激活树莓派主板 roslaunch clbrobot bringup.launch 开启摄像头 ...

  4. 03-webpack五个概念

  5. scrapy框架简介

    一.安装scrapy环境 -mac或linux:pip install scrapy -windows: 1.pip install wheel 2.pip install twinsted 3.pi ...

  6. B/S结构系统的会话机制(session)

    B/S结构系统的会话机制(session) 目录 B/S结构系统的会话机制(session) 每博一文案 1. session 会话机制的概述 2. 什么是 session 的会话 3. sessio ...

  7. 2022-03-30:有m个同样的苹果,认为苹果之间无差别, 有n个同样的盘子,认为盘子之间也无差别, 还有,比如5个苹果如果放进3个盘子, 那么1、3、1和1、1、3和3、1、1的放置方法,也认为是

    2022-03-30:有m个同样的苹果,认为苹果之间无差别, 有n个同样的盘子,认为盘子之间也无差别, 还有,比如5个苹果如果放进3个盘子, 那么1.3.1和1.1.3和3.1.1的放置方法,也认为是 ...

  8. status能否设置为布尔值类型,前端采用复选框形式

    是的,可以将status设置为布尔类型,这样可以在前端使用复选框形式展示.在模型中的定义可以如下: class Acceptance(models.Model): # ... status = mod ...

  9. transaction.atomic装饰器

    from django.shortcuts import renderfrom django.http import HttpResponsefrom django.views.generic imp ...

  10. Django 14天从小白到进阶- Day1 Django 初识

    来自作者:金角大王 本节内容 Http原理介绍 自行开发一个Web框架 WSGI介绍 Django介绍 MVC/MTV Django安装 创建项目与APP 开发第一个页面 为什么学Django? Go ...