vvvvip用户 2017-06-30 01:43 采纳率: 0%
浏览 1002

使用aop操作事务无效?

这是我xml中的配置

<bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager">
    <property name="sessionFactory" ref="sessionFactory" />  
</bean>
<!-- 使用注解事物 -->
<tx:annotation-driven transaction-manager="transactionManager"/>  

 <tx:advice id="txAdvice" transaction-manager="transactionManager">
    <tx:attributes>
       <!-- <tx:method name="*" read-only="true" /> -->
        <tx:method name="save*" propagation="REQUIRED" />
        <tx:method name="add*" propagation="REQUIRED" />
        <tx:method name="create*" propagation="REQUIRED" />
        <tx:method name="insert*" propagation="REQUIRED" />
        <tx:method name="update*" propagation="REQUIRED" />
        <tx:method name="merge*" propagation="REQUIRED" />
        <tx:method name="del*" propagation="REQUIRED" />
        <tx:method name="remove*" propagation="REQUIRED" />
        <tx:method name="put*" propagation="REQUIRED" />
        <tx:method name="use*" propagation="REQUIRED"/>
        <tx:method name="get*" propagation="REQUIRED" read-only="true" />
        <tx:method name="count*" propagation="REQUIRED" read-only="true" />
        <tx:method name="find*" propagation="REQUIRED" read-only="true" />
        <tx:method name="list*" propagation="REQUIRED" read-only="true" />
        <tx:method name="query*" propagation="REQUIRED" read-only="true" />

    </tx:attributes>
</tx:advice>
<aop:config  proxy-target-class="true">
    <aop:pointcut id="txPointcut" expression="execution(* *.*..*biz*.*(..))" />
    <aop:advisor advice-ref="txAdvice" pointcut-ref="txPointcut"/>
</aop:config>
 在dao层
    Session session=sessionFactory.getCurrentSession();
        User user=(User) session.createQuery("from User where dbm=:i").setParameter("i",dbm).uniqueResult();
        user.setPassword(newPassword);
        session.update(user);
        session.flush();
一直说我没有开启事务,哪位大哥快告诉我哪有问题
没有币啊,穷人
  • 写回答

2条回答 默认 最新

  • vvvvip用户 2017-06-30 02:03
    关注

    别的地方还有需要配置的么?

    评论

报告相同问题?

悬赏问题

  • ¥50 comsol稳态求解器 找不到解,奇异矩阵有1个空方程返回的解不收敛。没有返回所有参数步长;pid控制
  • ¥15 怎么让wx群机器人发送音乐
  • ¥15 fesafe材料库问题
  • ¥35 beats蓝牙耳机怎么查看日志
  • ¥15 Fluent齿轮搅油
  • ¥15 八爪鱼爬数据为什么自己停了
  • ¥15 交替优化波束形成和ris反射角使保密速率最大化
  • ¥15 树莓派与pix飞控通信
  • ¥15 自动转发微信群信息到另外一个微信群
  • ¥15 outlook无法配置成功