事务的传播行为(关于spring)
@Override
public Person getPerson(int id) {
Session s = this.getSession();
//为了测试事务的传播行为,特别将此处的事务打开,但是为什么没有报异常呢?
Transaction tx = s.getTransaction();
tx.begin();
Person p = (Person)s.get(Person.class,1);
return p;
}
--------------------编程问答-------------------- 查了些资料,说如果配置成为NEVER,如果运行时开启了事务,则会报异常,为什么我的没异常呢?
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<!-- REQUIRED:支持当前事务,如果没有事务,创建事务并执行 -->
<tx:method name="save*" propagation="REQUIRED"/>
<tx:method name="update*" propagation="REQUIRED"/>
<tx:method name="remove*" propagation="REQUIRED"/>
<tx:method name="add*" propagation="REQUIRED"/>
<!-- get设置为了NEVER -->
<tx:method name="get*" propagation="NEVER"/>
<!-- SUPPORTS:支持当前事务,如果没有事务,则按非事务方式运行 -->
<tx:method name="load*" propagation="SUPPORTS"/>
</tx:attributes>
</tx:advice>
--------------------编程问答--------------------
兄弟我也遇到类似的情况,也没报异常,不知道怎么回事?你现在解决了么? --------------------编程问答--------------------
那就看看你的aop:config是怎么配的,和包的目录 --------------------编程问答--------------------
http://bbs.csdn.net/topics/390474629
你看上面我遇到的问题,有详细的配置文件说明,不知道什么问题,麻烦给看看吧,感觉这个问题还不错
补充:Java , Web 开发