解决load,get,save 等is not valid without active transaction异常的原因。
来源:互联网 发布:网络主播幕后团队 编辑:程序博客网 时间:2024/05/19 13:30
Exception in thread "main" org.hibernate.HibernateException: *** is not valid without active transaction
at org.hibernate.context.ThreadLocalSessionContext$TransactionProtectionWrapper.invoke(ThreadLocalSessionContext.java:338)
at $Proxy13.getListeners(Unknown Source)
at org.hibernate.search.backend.impl.EventSourceTransactionContext.getIndexWorkFlushEventListener(EventSourceTransactionContext.java:78)
at org.hibernate.search.backend.impl.EventSourceTransactionContext.<init>(EventSourceTransactionContext.java:41)
at org.hibernate.search.impl.FullTextSessionImpl.<init>(FullTextSessionImpl.java:75)
at org.hibernate.search.Search.getFullTextSession(Search.java:23)
at com.yin.hibernate.model.GuestBookTest.main(GuestBookTest.java:28)
在网上找的原因是:
如果使用hibernate的getCurrentSession()获得session对象,对查询语句也需要开启事务,不然就会抛出如上异常!
解决方法:
加上 Transaction tx = session.beginTransaction();
tx.commit();
注意:在 hibernate.cfg.xml
如果采用jdbc独立引用程序配置如下:
<property name=”hibernate.current_session_context_class”>thread</property>
如果采用了JTA事务配置如下
<property name=”hibernate.current_session_context_class”>jta</property>
- 解决load,get,save 等is not valid without active transaction异常的原因。
- 解决load,get,save 等is not valid without active transaction异常的原因。
- 解决load,get,save 等is not valid without active transaction异常的原因
- org.hibernate.HibernateException: save is not valid without active transaction
- org.hibernate.HibernateException: save is not valid without active transaction
- spring+hibernate进行线程操作时异常:save is not valid without active transaction
- hibernate错误:load is not valid without active transaction
- createQuery is not valid without active transaction异常
- createQuery is not valid without active transaction
- getFlushMode is not valid without active transaction
- createQuery is not valid without active transaction
- createQuery is not valid without active transaction
- getHibernateFlushMode is not valid without active transaction;
- getFlushMode is not valid without active transaction
- createSQLQuery is not valid without active transaction的解决办法
- spring声明式管理事务+ hibernate + save is not valid without active transaction
- org.hibernate.HibernateException: save is not valid without active transaction at org.hibernate.co
- spring 管理 hibernate 事务 load is not valid without active transaction
- PCLint使用经验分享(有问有答)
- C++实例 堆排序
- 开源代码网址大全
- 1025. PAT Ranking
- matlab画图:绘制双图,上图以条形图(分割开来的两根bar),下图是残差。。。横坐标为日期
- 解决load,get,save 等is not valid without active transaction异常的原因。
- ArcGIS Runtime支持的GP工具列表(转 )
- 老板不在时为老板处理一些事务
- Android设置对话框风格的Activity
- UVa 10152 - ShellSort
- 堆和栈
- windows 2003 设置或更改管理员密码
- 剩余电量测量
- dup,dup2函数的用法