org.hibernate.HibernateException: No CurrentSessionContext configured!
at org.hibernate.internal.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:695)
at cn.itcast.utils.HibernateUtils.getSessionObject(HibernateUtils.java:20)
at cn.itcast.hibernatetest.HibernateSelect.testTx01(HibernateSelect.java:19)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)

可能是使用getCurrentSession()出现了问题,问题原因可能是hibernate.cfg.xml文件中的

<!-- 在hibernate核心配置文件中配置 -->
<property name="hibernate.current_session_context_class">thread</property>

没有配置对。修改便是。

hibernate报错org.hibernate.HibernateException: No CurrentSessionContext configured!的更多相关文章

  1. Hibernate 报错org.hibernate.PropertyAccessException: IllegalArgumentException(已解决)

    无聊想搭建一个项目,练手,做点小功能就一个卡在这个问题上 org.hibernate.PropertyAccessException: IllegalArgumentException occurre ...

  2. hibernate报错org.hibernate.SessionException: Session was already closed

    org.hibernate.SessionException: Session was already closedat org.hibernate.internal.SessionImpl.clos ...

  3. Hibernate(三): org.hibernate.HibernateException: No CurrentSessionContext configured!

    Hibernate版本5.2.9 获取Session的方式是sessionFactory.getCurrentSession(); 比较老一些的版本使用的是sessionFactory.openSes ...

  4. Hibernate报错,关于配置的SessionFactory找不到问题

    最近写项目使用hibernate默认的dtd,在启动项目时经常会出现这个问题,hibernate报错,配置factory的id找不到,找不到mapping配置文件, 不能读取配置的xml文件 Coul ...

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

  6. spring+hibernate整合:报错org.hibernate.HibernateException: No Session found for current thread

    spring+hibernate整合:报错信息如下 org.hibernate.HibernateException: No Session found for current thread at o ...

  7. Hibernate中报错org.hibernate.HibernateException: No CurrentSessionContext configured!

    报错信息如下: 解决方法: 问题原因是getCurrentSession()出现了问题 在hibernate.cfg.xml(hibernate的核心配置文件)文件中加入下列代码: <prope ...

  8. Hibernate报错:org.hibernate.ObjectNotFoundException: No row with the given identifier exists 解决办法

    报错信息: org.hibernate.event.internal.DefaultLoadEventListener onLoad INFO: HHH000327: Error performing ...

  9. hibernate报错Unknown integral data type for ids : java.lang.String

    package com.model; // Generated 2016-10-27 14:02:17 by Hibernate Tools 4.3.1.Final /** * CmDept gene ...

随机推荐

  1. LR回放https协议脚本失败:[GENERAL_MSG_CAT_SSL_ERROR]connect to host "XXX" failed:[10054] Connection reset by peer [MsgId:MERR-27780]

    最近做一个负载均衡项目的性能测试,使用LR录制脚本协议为https协议,回放脚本时出现报错: [GENERAL_MSG_CAT_SSL_ERROR]connect to host "XXX& ...

  2. [HEOI2014]南园满地堆轻絮

    [HEOI2014]南园满地堆轻絮 BZOJ luogu 二分答案贪心check 首先b[1]最小一定优 之后就贪心的最小化b[i]就行 #include<bits/stdc++.h> u ...

  3. MySQL中lock与latch的区分

    这里要区分锁中容易令人混淆的概念lock与latch.在数据库中,lock与latch都可以成为锁,但两者有截然不同的含义 latch 一般称为闩锁(轻量级的锁) 因为其要求锁定的时间非常短,若迟勋时 ...

  4. SPDY

    转载SPDY 是什么 SPDY 是 Google 开发的基于传输控制协议 (TCP) 的应用层协议 ,开发组正在推动 SPDY 成为正式标准(现为互联网草案).SPDY 协议旨在通过压缩.多路复用和优 ...

  5. 常用mongo语句

    只列出指定字段db.getCollection('PUBLICACCOUNTS').find({},{NickName:1,UserName:1,FID:1,_id:0})获取微信公众号列表db.ge ...

  6. boost之智能指针

    内存问题永远是c++中讨论的重要话题 1.c98 auto_ptr的实现,auto_ptr的特点是始终只保持一个指针指向对象,若经过赋值或者拷贝之后原指针失效 #include <iostrea ...

  7. Verilog HDL设计规范及经验谈(转载)

    1. 规范很重要      工作过的朋友肯定知道,公司里是很强调规范的,特别是对于大的设计(无论软件还是硬件),不按照规范走几乎是不可实现的.逻辑设计也是这样:如果不按规范做的话,过一个月后调试时发现 ...

  8. Summaries On Java

    @1:== 和 equals(): ==用于比较引用和比较基本数据类型时具有不同的功能: 比较基本数据类型:如果两个值相同,则结果为true. 比较引用:如果引用指向内存中的同一对象,结果为true( ...

  9. python更新模块

    pip install -U 模块名 # 这是 python2+ 版本的用法更新模块 pip3 install -U 模块名 # 这是 python3+ 版本的用法更新模块

  10. 顽石系列:Linux基础笔试

    顽石系列:Linux基础笔试 系统操作 压缩文件 扩展名 压缩程序 *.Z compress *.zip zip *.gz gzip *.bz2 bzip2 *.xz xz *.tar tar 程序打 ...