博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Spring framework3.2整合hibernate4.1报错:No Session found for current thread
阅读量:7096 次
发布时间:2019-06-28

本文共 421 字,大约阅读时间需要 1 分钟。

getCurrentSession需要做如下配置:

thread

1. 前者打开一个新的,后者当前有session的话,则是使用当前的session,没有的话则创建一个新的;

2. 如果使用前者获得一个session的话,需要手动关闭session,使用后者,当事务提交,session会自动关闭,如果再关闭session则会报如下异常:Session has already closed;

3. sf.getCurrentSession方法需要在hibernate.cfg.xml做如下配置:

    <propertynamepropertyname="current_session_context_class" >thread</property>  

没有配置的话会报如下异常:org.hibernate.HibernateException:No CurrentSessionContext configured!

转载地址:http://hwaql.baihongyu.com/

你可能感兴趣的文章
zabbix 在php7 下安装 always-populate-raw-post-data = -1 问题
查看>>
nagios邮件报警
查看>>
python快速求解不定积分和定积分
查看>>
Mongo cheatsheet(速查页)
查看>>
常用服务器模型总结
查看>>
Aho Corasick自动机结合DoubleArrayTrie极速多模式匹配
查看>>
term node count
查看>>
Direct2D (36) : RenderTarget.DrawText() 与 IDWriteTextFormat
查看>>
详测 Generics Collections TList (8): Sort
查看>>
显示系统托盘列表(并执行隐藏与显示) - 回复 "anybet" 的问题
查看>>
一句话判断网络是否联通
查看>>
再学 GDI+[85]: TGPImage(5) - RotateFlip - 旋转与镜像
查看>>
Delphi 与 DirectX 之 DelphiX(42): TDIB.GaussianBlur();
查看>>
获取时间戳 和 备用ajax案例
查看>>
rsyslog+mysql+loganalyzer构建日志服务器
查看>>
linux文件最大连接数问题---bash:ulimit:open files:cannot modify limit:Operation not permitted...
查看>>
使用exp进行SQL报错注入
查看>>
iKcamp新书上市《Koa与Node.js开发实战》
查看>>
2015年十大测试工具你认识几个
查看>>
基于订阅的服务通讯架构体系
查看>>