<tx:advice/> Settings

本节总结了你可以使用 <tx:advice/> 标签指定的各种事务设置。<tx:advice/> 的默认设置如下:

This section summarizes the various transactional settings that you can specify by using the <tx:advice/> tag. The default <tx:advice/> settings are:

  • propagation setting 是`REQUIRED.`

  • The propagation setting is REQUIRED.

  • 隔离级别是 DEFAULT.

  • The isolation level is DEFAULT.

  • The transaction is read-write.

  • 交易超时默认为底层交易系统的默认超时,如果没有支持超时,则为无。

  • The transaction timeout defaults to the default timeout of the underlying transaction system or none if timeouts are not supported.

  • 任何 RuntimeException 触发回滚,且任何已检查的 Exception 不会触发回滚。

  • Any RuntimeException triggers rollback, and any checked Exception does not.

你可以更改这些默认设置。下表总结了嵌套于 <tx:advice/><tx:attributes/> 标签中的 <tx:method/> 标签的各种属性:

You can change these default settings. The following table summarizes the various attributes of the <tx:method/> tags that are nested within <tx:advice/> and <tx:attributes/> tags:

Table 1. <tx:method/> settings
Attribute Required? Default Description

name

Yes

Method names with which the transaction attributes are to be associated. The wildcard () character can be used to associate the same transaction attribute settings with a number of methods (for example, get, handle*, on*Event, and so forth).

propagation

No

REQUIRED

Transaction propagation behavior.

isolation

No

DEFAULT

Transaction isolation level. Only applicable to propagation settings of REQUIRED or REQUIRES_NEW.

timeout

No

-1

Transaction timeout (seconds). Only applicable to propagation REQUIRED or REQUIRES_NEW.

read-only

No

false

Read-write versus read-only transaction. Applies only to REQUIRED or REQUIRES_NEW.

rollback-for

No

Comma-delimited list of Exception instances that trigger rollback. For example, com.foo.MyBusinessException,ServletException.

no-rollback-for

No

Comma-delimited list of Exception instances that do not trigger rollback. For example, com.foo.MyBusinessException,ServletException.