spring PROPAGATION_REQUIRED事务属性问题
<bean id="addPerson"
class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="transactionManager"><ref local="t2"/></property>
<property name="target"><ref local="addPersonTarget"/></property>
<property name="transactionAttributes">
<props>
<prop key="addUser">PROPAGATION_SUPPORTS</prop>
<prop key="addPerson">PROPAGATION_REQUIRED</prop>
</props>
</property>
</bean>
<bean id="trantTest" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="transactionManager"><ref local="t2"/></property>
<property name="target"><ref local="trantTestTarget"/></property>
<property name="transactionAttributes">
<props>
<prop key="add">PROPAGATION_NEVER</prop>
</props>
</property>
</bean>
trantTest bean 调用 addPerson 方法如下:
public void add()
{
addPerson.addUser();
addPerson.addPerson();
}
问题出来了,如果addPerson.addPerson()出错,addPerson.addUser();方法插入成功数据一样被回滚,
按道理,addUser()运行时候,没有事务,则插入的数据应自动作为一个事务递交,不管后来是否发生异常,
谁来解释一下?