HibernateException: Could not obtain transaction-synchronized Session for current thread
来源:互联网 发布:决战武林神兵进阶数据 编辑:程序博客网 时间:2024/04/20 12:20
使用hibernate4的SessionFactory获取Session时有两种方式
1、sessionFactory.getCurrentSession()
2、sessionFactory.openSession(),开启新session,需要关闭
当使用1获取CurrentSession,不会开启新的session,速度要快。但是如果你是使用多线程的时候,就不能使用getCurrentSession,这样会报以下错误
org.hibernate.HibernateException: Could not obtain transaction-synchronized Session for current thread
只需要改成openSession方式就可以解决了
1 0
- HibernateException: Could not obtain transaction-synchronized Session for current thread
- HibernateException: Could not obtain transaction-synchronized Session for current thread 的解决方法。
- 多线程出现HibernateException: Could not obtain transaction-synchronized Session for current thread
- 【Hibernate】Could not obtain transaction-synchronized Session for current thread
- Could not obtain transaction-synchronized Session for current thread
- Could not obtain transaction-synchronized Session for current thread
- Could not obtain transaction-synchronized Session for current thread
- Could not obtain transaction-synchronized Session for current thread
- Could not obtain transaction-synchronized Session for current thread
- Could not obtain transaction-synchronized Session for current thread
- Could not obtain transaction-synchronized Session for current thread
- Could not obtain transaction-synchronized Session for current thread
- Could not obtain transaction-synchronized Session for current thread
- Could not obtain transaction-synchronized Session for current thread
- Could not obtain transaction-synchronized Session for current thread
- Could not obtain transaction-synchronized Session for current thread
- Could not obtain transaction-synchronized Session for current thread
- Could not obtain transaction-synchronized Session for current thread
- Xshell使用教程及WinSCP使用教程
- AFNetWorking 监听网络连接的状态
- datetimepicker-bootstrap默认年份1899修改问题
- linux下使用swig让python调用C++(复杂版:包括多文件调用和链接库)
- 什么是实时应用程序自我保护(RASP)?
- HibernateException: Could not obtain transaction-synchronized Session for current thread
- Linux指令--mkdir
- 深入理解PHP7之zval
- Linux下更改目录及其下的子目录和文件的访问权限
- Windows 10下Markdown不能显示预览
- 使用状态模式解决简单的信号转换问题
- 【jQuery】调用trigger()方法手动触发指定的事件
- 黑马程序员--Java编程之多线程
- Java HttpClient解析https时报错Could not generate DH keypair