首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件架构设计 >

使用spring的aop管理hibernate事务的有关问题

2012-09-05 
使用spring的aop管理hibernate事务的问题使用spring的aop管理hibernate事务的问题悬赏分:50 | 解决时间:20

使用spring的aop管理hibernate事务的问题
使用spring的aop管理hibernate事务的问题
悬赏分:50 | 解决时间:2010-2-23 12:56 | 提问者:wangyu1221

配置文件如下
<!-- 配置切面 -->
<aop:config proxy-target->
  <aop:pointcut id="servicePointcut" expression="execution(* com.orm.hr.dao.*.*(..))" />
  <aop:advisor advice-ref="txAdvice" pointcut-ref="servicePointcut" />
</aop:config>
<tx:advice id="txAdvice" transaction-manager="transactionManager">
  <tx:attributes>
   <tx:method name="add*" propagation="REQUIRED" rollback-for="Exception"/>
   <tx:method name="update*" propagation="REQUIRED" rollback-for="Exception"/>
   <tx:method name="delete*" propagation="REQUIRED" rollback-for="Exception"/>
   <tx:method name="*" read-only="true"/>
  </tx:attributes>
</tx:advice>

这样的话,运行正常没有问题

但是,这样切面是在dao层。我想把切面放在service层,应该怎么做?

我尝试直接修改execution为(* com.orm.hr.service.*.*(..)),也能运行,但是事务不提交。

问题补充:

<tx:method name="*" propagation="REQUIRED" rollback-for="Exception"/>

这样也不行啊

最佳答案

service层的方法名也要是add..update..delete..才会事务

分享给你的朋友吧:

    * 人人网
    * 新浪微博
    * 开心网
    * MSN
    * QQ空间

对我有帮助
1

热点排行