快速业务通道

Spring事务管理高级应用难点剖析: 第2部分 - 编程入门网

作者 佚名技术 来源 NET编程 浏览 发布时间 2012-06-13
quot;org.springframework.orm.hibernate3.HibernateTransactionManager"    p:sessionFactory-ref="sessionFactory"/> <!-- 对所有继承 BaseService类的公用方法实施事务增强 --> <aop:config proxy-target- class="true">   <aop:pointcut id="serviceJdbcMethod"      expression="within(user.mixdao.BaseService+)"/>   <aop:advisor  pointcut-ref="serviceJdbcMethod"     advice-ref="hiberAdvice"/> </aop:config> <tx:advice id="hiberAdvice" transaction- manager="hiberManager">   <tx:attributes>      <tx:method name="*"/>   </tx:attributes> </tx:advice>

启动 Spring 容器,执行 UserService#logon() 方法, 可以查看到如下的执行日志:

清单 5. 代码运行日志

12:38:57,062  (AbstractPlatformTransactionManager.java:365) - Creating new transaction   with name [user.mixdao.UserService.logon]:  PROPAGATION_REQUIRED,ISOLATION_DEFAULT 12:38:57,093  (SessionImpl.java:220) - opened session at timestamp: 12666407370  12:38:57,093 (HibernateTransactionManager.java:493) - Opened new Session   [org.hibernate.impl.SessionImpl@83020] for Hibernate transaction ①  12:38:57,093 (HibernateTransactionManager.java:504) - Preparing JDBC  Connection   of Hibernate Session [org.hibernate.impl.SessionImpl@83020] 12:38:57,109 (JDBCTransaction.java:54) - begin … logon method...  updateLastLogonTime...  … 12:38:57,109 (AbstractBatcher.java:401) - select  user0_.USER_NAME as USER1_0_0_,   user0_.LAST_LOGON_TIME as LAST2_0_0_,  user0_.password as password0_0_,  user0_.score as score0_0_ from  T_USER user0_ where user0_.USER_NAME=? Hibernate: select  user0_.USER_NAME as USER1_0_0_,  user0_.LAST_LOGON_TIME as LAST2_0_0_,  user0_.password as password0_0_,  user0_.score as score0_0_ from T_USER  user0_ where user0_.USER_NAME=? … 12:38:57,187  (HibernateTemplate.java:422) - Not closing pre-bound   Hibernate  Session after HibernateTemplate 12:38:57,187  (HibernateTemplate.java:397) - Found thread-bound Session   for  HibernateTemplate Hibernate: update T_USER set LAST_LOGON_TIME=?,  password=?, score=? where USER_NAME=? … 2010-02-20  12:38:57,203 DEBUG [main] (AbstractPlatformTransactionManager.java:470)   - Participating in existing transaction ②  addScore...  2010-02-20 12:38:57,203 DEBUG [main] (JdbcTemplate.java:785)   -  Executing prepared SQL update 2010-02-20 12:38:57,203 DEBUG [main]  (JdbcTemplate.java:569)   - Executing prepared SQL statement   [UPDATE t_user u SET u.score = u.score + ? WHERE user_name =?] 2010-02-20 12:38:57,203 DEBUG [main] (JdbcTemplate.java:794)   - SQL  update affected 1 rows  激活连接数量:1 ③ 2010-02-20  12:38:57,203 DEBUG [main] (AbstractPlatformTransactionManager.java:752)

凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!

分享到: 更多

Copyright ©1999-2011 厦门凌众科技有限公司 厦门优通互联科技开发有限公司 All rights reserved

地址(ADD):厦门软件园二期望海路63号701E(东南融通旁) 邮编(ZIP):361008

电话:0592-5908028 传真:0592-5908039 咨询信箱:web@lingzhong.cn 咨询OICQ:173723134

《中华人民共和国增值电信业务经营许可证》闽B2-20100024  ICP备案:闽ICP备05037997号