做了一道面试的选择题,讲的是spring的事务传播特性,如下:
下面有关SPRING的事务传播特性,说法错误的是?
A: PROPAGATION_SUPPORTS:支持当前事务,如果当前没有事务,就以非事务方式执行
B: PROPAGATION_REQUIRED:支持当前事务,如果当前没有事务,就抛出异常
C: PROPAGATION_REQUIRES_NEW:新建事务,如果当前存在事务,把当前事务挂起
D: PROPAGATION_NESTED:支持当前事务,新增Savepoint点,与当前事务同步提交或回滚
来源: http://www.nowcoder.com/questionTerminal/1c65d30e47fb4f59a5e5af728218cac4
答案选 B
下面我在spring 3 API中看到的,然后自己翻译了一下,但是对于事务同步范围这个不是很懂,有知道的欢迎在下面评论,感谢!
PROPAGATION_REQUIRED
Support a current transaction; create a new one if none exists.
支持一个当前事务;如果不存在,创建一个新的。
This is typically the default setting of a transaction definition, and typically defines a transaction synchronization scope.
默认设置,后面的不懂
PROPAGATION_SUPPORTS
Support a current transaction; execute non-transactionally if none exists.
支持当前事务;如果不存在当前事务则执行非事务。
PROPAGATION_NOT_SUPPORTED
Do not support a current transaction; rather always execute non-transactionally.
不执行当前事务;而是总是执行非事务
PROPAGATION_REQUIRES_NEW
Create a new transaction, suspending the current transaction if one exists.
创建一个新的事务,如果存在当前事务的话暂停(挂起)当前事务 。
PROPAGATION_NESTED
Execute within a nested transaction if a current transaction exists
如果当前存在事务的话,执行一个嵌套的事务
PROPAGATION_NEVER
Do not support a current transaction; throw an exception if a current transaction exists.
不支持当前事务;如果存在当前事务则抛出一个异常
PROPAGATION_MANDATORY
Support a current transaction; throw an exception if no current transaction exists.
支持当前事务;如果不存在当前事务则抛出一个异常