手机版
你好,游客 登录 注册
背景:
阅读新闻

Spring 集成hibernate事务管理(aop实现)

[日期:2012-07-02] 来源:Linux社区  作者:without0815 [字体:大 中 小]
  1. <bean id="transactionManager"  
  2.         class="org.springframework.orm.hibernate3.HibernateTransactionManager">  
  3.         <property name="sessionFactory">  
  4.             <ref bean="sFactory" />  
  5.         </property>  
  6.     </bean>  
  7.       
  8.     <tx:advice id="txAdvice" transaction-manager="transactionManager">  
  9.         <tx:attributes>  
  10.             <tx:method name="*" propagation="REQUIRED" />  
  11.         </tx:attributes>  
  12.     </tx:advice>  
  13.   
  14.     <aop:config>  
  15.         <aop:pointcut id="tx" expression="execution(* org.ymm.services.LoginService.*(..))" />  
  16.         <aop:advisor advice-ref="txAdvice" pointcut-ref="tx" />  
  17.     </aop:config>  

Spring中进行事务管理也是利用AOP(面向切片编程)的方式,spring在通过拦截器,加载事务.

bean是创建了一个事务管理,

tx是对拦截切面的描述

aop是配置一个切面

当我们配置完了,最重要的是得到spring创建的当前CurrentSession

  1. <!-- <prop key="hibernate.current_session_context_class">thread</prop> -->  
  2.     <prop key="hibernate.current_session_context_class">org.springframework.orm.hibernate3.SpringSessionContext</prop>  
linux
相关资讯       Spring  Spring教程 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款