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

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

    评论

报告相同问题?

悬赏问题

  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能
  • ¥15 jmeter脚本回放有的是对的有的是错的
  • ¥15 r语言蛋白组学相关问题