Acaleph 2009-05-13 14:16
浏览 240
已采纳

SPRING环境下如何配事务

1 先保存一个对象,比如一个job对象。
2 取的刚保存完成的job对象的id,放到另外一个对象的属性中,也可能是N属性对象组成的LIST。
为了保持数据一致性,如何配置这个事务?用注释最好。
[b]问题补充:[/b]
开发环境:[color=red]Struts2 + Spring2.5.6 + Hibernate3.2.0.ga[/color]
[b]问题补充:[/b]
谢谢大家的支持,这30分给谁呢?平均分配吧,网站不支持。你俩商量一下,给我个决定。
我还是倾向于用注释来解决这个问题。

  • 写回答

7条回答 默认 最新

  • weixin_42297497 2009-05-14 09:26
    关注
     <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
        <property name="sessionFactory">
            <ref local="sessionFactory"/>
        </property>
    </bean>
    
    <aop:config proxy-target-class="true">
        <aop:advisor pointcut="execution(* com.incesoft.security.acegi.logic.service.impl.*ServiceImpl.*(..))" advice-ref="txAdvice"/>     
        <aop:advisor pointcut="execution(* com.incesoft.business.maintain.service.impl.*ServiceImpl.*(..))" advice-ref="txAdvice"/>
        <aop:advisor pointcut="execution(* com.incesoft.business.manage.service.impl.*ServiceImpl.*(..))" advice-ref="txAdvice"/>       
    </aop:config>
    
    <tx:advice id="txAdvice">
        <tx:attributes>
            <tx:method name="get*" read-only="true"/>
            <tx:method name="find*" read-only="true"/>
            <tx:method name="query*" read-only="true"/>
            <tx:method name="load*" read-only="true"/>
            <tx:method name="search*" read-only="true"/>
            <tx:method name="*" />
            <tx:method name="*Faq*" no-rollback-for="com.incesoft.business.commons.ServiceException"/>
            <tx:method name="*faq*" no-rollback-for="com.incesoft.business.commons.ServiceException"/>
            <tx:method name="*Chat*" no-rollback-for="com.incesoft.business.commons.ServiceException"/>
            <tx:method name="*chat*" no-rollback-for="com.incesoft.business.commons.ServiceException"/>
        </tx:attributes>
    </tx:advice>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(6条)

报告相同问题?

悬赏问题

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