Spring3 xml配置事务子类能否继承抽象类

Spring3用xml配置事务

    <tx:advice id="txAdvice" transaction-manager="transactionManager">
        <tx:attributes>
            <tx:method name="find*" propagation="REQUIRED" read-only="true" rollback-for="Exception"/>
            <tx:method name="get*" propagation="REQUIRED" read-only="false" rollback-for="Exception"/>
            <tx:method name="*" propagation="REQUIRED" rollback-for="Exception"/>
        </tx:attributes>
    </tx:advice>

    <!-- aop切面定义 -->
    <aop:config>
        <!-- <aop:advisor pointcut="execution(* com.gree.aftermarket.*.service.impl.*.*(..))" advice-ref="txAdvice" />     -->
        <aop:advisor pointcut="execution(* com.proj.aftermarket.*.service.impl.*.*(..))" advice-ref="txAdvice" />    
    </aop:config>
public JSONObject typeUnitAnalyse(int a) {
        boolean isok;
        try {
            if (a = 1) {
                isok = analyseLogin();
            }else if(a = 2){
                isok = analyseLogout();
            }
        }
        // ......
}
protected abstract boolean analyseLogin();
protected abstract boolean analyseLogout();

所有请求的入口都是typeUnitAnalyse(),
我在子类继承analyseLogin()重写方法,用hibernate进行了如下判断:
查询是否有id,如果没有则写入,如果有则更新
当我这个函数几乎同时执行两次的时候,同一个id全部判断为空,进行了两次插入操作
这是不是代表事务没有起作用?

阅读 1.3k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题