使用ssh出现 Could not obtain transaction-synchronized Session for current thre情况
来源:互联网 发布:跑步软件修改器 编辑:程序博客网 时间:2024/06/07 22:24
这个调试是基于Hibernate4 的getSessionFactory().getCurrentSession()那个Hibernate3的HibernateTemplate().get(entityClazz, id);也适合,如果出现下面的bug
org.hibernate.HibernateException: Could not obtain transaction-synchronized Session for current thre
是因为我们未对Service层加上事务管理
我们应该在applicationContext.xml中配置
<!-- 配置Hibernate的局部事务管理器,使用HibernateTransactionManager类 并注入SessionFactory的引用 --><bean id="transactionManager"class="org.springframework.orm.hibernate4.HibernateTransactionManager"p:sessionFactory-ref="sessionFactory" />
注意
<!-- 可有可无 --><tx:annotation-driven transaction-manager="transactionManager" /><!-- 配置事务增强处理Bean,指定事务管理器 --><tx:advice id="txAdvice" transaction-manager="transactionManager"><!-- 用于配置详细的事务语义 --><tx:attributes><!-- 所有以'get'开头的方法是read-only的 --><tx:method name="get*" read-only="true" /><!-- 其他方法使用默认的事务设置 --><tx:method name="*" /></tx:attributes></tx:advice><aop:config><!-- 配置一个切入点,匹配empManager和mgrManager 两个Bean的所有方法的执行 --><aop:pointcut id="leePointcut"expression="bean(customerDoDishes) or bean(customerDoMessage) or bean(customerDoNotice) or bean(customerDoOrder) or bean(customerDoOwn) or bean(commonDoDishes)" /><!-- 指定在leePointcut切入点应用txAdvice事务增强处理 --><aop:advisor advice-ref="txAdvice" pointcut-ref="leePointcut" /></aop:config>
<
0 0
- 使用ssh出现 Could not obtain transaction-synchronized Session for current thre情况
- org.hibernate.HibernateException: Could not obtain transaction-synchronized Session for current thre
- org.hibernate.HibernateException: Could not obtain transaction-synchronized Session for current thre
- org.hibernate.HibernateException: Could not obtain transaction-synchronized Session for current thre
- SSH整合时出现Could not obtain transaction-synchronized Session for current thread
- ssh整合 出现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
- HibernateException: 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
- 把word excel ppt 导入到右键快捷菜单中
- 不熟悉的关键字们
- Download Fedora 16 CD / DVD ISO
- 重写ImageSwtichView
- make、cmake、make install、configure
- 使用ssh出现 Could not obtain transaction-synchronized Session for current thre情况
- Laxcus大数据管理系统2.0(10)- 第八章 安全
- ISO C90 forbids mixed declarations and code[-Wdeclaration-after-statement]
- MySQL安装.md
- Laxcus大数据管理系统2.0(11)- 第九章 容错
- incrementProgressBy函数
- 队列实现简单的dfs算法
- Java的数据类型转换
- Laxcus大数据管理系统2.0(12)- 第十章 运行