<tx:advice id="txAdvice" transaction-manager="myHibTxManager">
<tx:attributes> <tx:method name="get*" propagation="SUPPORTS" read-only="true" />
<tx:method name="load*" propagation="SUPPORTS" read-only="true" />
<tx:method name="search*" propagation="SUPPORTS" read-only="true" />

<tx:method name="*" propagation="REQUIRED" />
</tx:attributes >
</tx:advice>
<aop:config>

<aop:pointcut id="serviceMethods" 
expression="execution(* com.crm.serviceimpl.*.*(..))" />

<aop:advisor advice-ref="txAdvice" pointcut-ref="serviceMethods" />
</aop:config>
高手解释一下

解决方案 »

  1.   

     我也才学。。你查下。spring的aop。。
      

  2.   

    你是做的 SSH 集成开发    <tx:advice id="txAdvice" transaction-manager="myHibTxManager">
            <tx:attributes>            <tx:method name="get*" propagation="SUPPORTS" read-only="true" />
                <tx:method name="load*" propagation="SUPPORTS" read-only="true" />
                <tx:method name="search*" propagation="SUPPORTS" read-only="true" />
                
                <tx:method name="*" propagation="REQUIRED" />    
            </tx:attributes >
        </tx:advice>
    这一段 是定义  事务的传播特性 和 是否 对 异常进行处理 你看你的都是使用的  propagation="SUPPORTS 说明是 当前 业务如果运行在事务中就使用改事务 如果没有事务就以无事务方式运行  <aop:config>
            
            <aop:pointcut id="serviceMethods" 
                expression="execution(* com.crm.serviceimpl.*.*(..))" />
            
            <aop:advisor advice-ref="txAdvice" pointcut-ref="serviceMethods" />
        </aop:config>
    这个是配置你的 切入点
    pointcut  指定的id expression指定改切入点 运用到那些 接入点上 com.crm.serviceimpl.*.*(..))" 是com.crm.serviceimpl下面的所有包的所有类的所有方法下面:
    <aop:advisor 
    定义通知  把上面定义处理事务的通知txAdvice(切面)  运用到 serviceMethods搞切入点上 
    最后的效果就是:    你的serviceimpl里面的所有类的所有方法 都是有spring来管理hibernate事务 ,使用的使用 要注意 hibernateTemplate的使用