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
    关注

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

    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器