在spring中配置事务:
引用
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<context:annotation-config/>
<!-- 使用annotation定义事务 -->
<tx:annotation-driven transaction-manager="transactionManager" />
<context:component-scan base-package="com.simstudy"/>
如果用@Transactional事务管理的类中同时配置了@Service导致Spring扫描到此类,就不会自动flush,必须手动flush,当然还可以不配置@Service,在Spring配置文件中直接配置bean。
这算不算Spring的一个bug呢
分享到:
相关推荐
关于在使用 hibernate 在提交事务时常遇到的异常: ...其实这个异常一般都是和我们在操作session flush方法和提交事务过程中会抛出的,下面就具体结合session的事务和声明周期来具体分析下,为什么会有这样的异常;
博文链接:https://llying.iteye.com/blog/221702
对hibernate的flush机制有兴趣可以看看
Struts+Spring+Hibernate实现上传下载 本文将围绕SSH文件上传下载的主题,向您详细讲述如何开发基于SSH的Web程序。SSH各框架的均为当前最新版本: •Struts 1.2 •Spring 1.2.5 •Hibernate 3.0 本文...
NULL 博文链接:https://wuhaidong.iteye.com/blog/766562
主要介绍了Hibernate的Session_flush与隔离级别代码详解,分享了相关代码示例,小编觉得还是挺不错的,具有一定借鉴价值,需要的朋友可以参考下
主要介绍了深入理解Hibernate中的flush机制,本文是对flush机制深入研究得出的一些结论总结,需要的朋友可以参考下
Collection类型属性中 <br>............... <br> ............... <br> 27.Spring的参数化事务管理功能相当强大,笔者建议在基于Spring Framework的应用 开发中,尽量使用容器管理事务,以...
3.6. Hibernate事务属性 3.7. 其他属性 3.8. Hibernate SQL方言 (hibernate.dialect) 3.9. Hibernate日志类别 3.10. JTA TransactionManagers 9.1. 继承映射特性(Features of inheritance mappings) 16.1. ...
首先session是有一级缓存的,目的是为了减少查询数据库的时间,提高效率,一级缓存的生命周期和session是一样的, session.flush()和session.clear...该方法的有效性需要配置事务的隔离级别为read commited(读已提交)。
3.6. Hibernate事务属性 3.7. 其他属性 3.8. Hibernate SQL方言 (hibernate.dialect) 3.9. Hibernate日志类别 3.10. JTA TransactionManagers 9.1. 继承映射特性(Features of inheritance mappings) 16.1. ...
3.6. Hibernate事务属性 3.7. 其他属性 3.8. Hibernate SQL方言 (hibernate.dialect) 3.9. Hibernate日志类别 3.10. JTA TransactionManagers 9.1. 继承映射特性(Features of inheritance mappings) 16.1. ...
Session对象.flush(); //将Session中的缓存内容提交到数据库 Session对象.clear(); //清空Session中的所有缓存(彻底清除会话) Session对象.beginTransaction().begin(); //开始一个事务 4.用Session对象的以下...
在Hibernate中使用两极缓存结构,第一级缓存是Session级别的缓存,Session级别的缓存是由Hibernate管理的,一般情况下无需进行干预.第二级缓存是 SessionFactory级别的缓存,SessionFactory级的缓存可以进行配置和...
session flush测试(hibernate_session_flush) 12 hihernate一对多关联映射(单向Classes----->Student) 13 hihernate一对多关联映射(双向Classes<----->Student)(常用) 14 hibernate一对多双向自连接关联映射...
管理Session缓存 14.5. 查询缓存(Query Cache) 15. 工具箱指南 15.1. Schema 生成器(Schema Generation) 15.1.1. 对schema定制化(Customizing the schema) 15.1.2. 运行该工具 15.1.3. 属性...
10.10. Session刷出(flush) 10.11. 传播性持久化(transitive persistence) 10.12. 使用元数据 11. 事务和并发 11.1. Session和事务范围(transaction scope) 11.1.1. 操作单元(Unit of work) 11.1.2. 长对话 ...
10.10. Session刷出(flush) 10.11. 传播性持久化(transitive persistence) 10.12. 使用元数据 11. 事务和并发 11.1. Session和事务范围(transaction scope) 11.1.1. 操作单元(Unit of work) 11.1.2. 长对话 11.1.3. ...
19.3. 管理缓存(Managing the caches) 19.4. 查询缓存(The Query Cache) 19.5. 理解集合性能(Understanding Collection performance) 19.5.1. 分类(Taxonomy) 19.5.2. Lists, maps 和sets用于更新效率...
1. Hibernate入门 1.1. 前言 1.2. 第一部分 - 第一个Hibernate应用程序 1.2.1. 第一个class 1.2.2. 映射文件 1.2.3. Hibernate配置 1.2.4. 用Ant构建 1.2.5. 启动和辅助类 1.2.6. 加载并存储对象 1.3. 第...