Spring Propagation types

Spring交易的屬性介紹

https://openhome.cc/Gossip/SpringGossip/TransactionAttribute.html

Propagation behavior:

MANDATORY
Support a current transaction, throw an exception if none exists.

Does not start a new Transaction, just checks whether a transaction is active (must be inside either another @Transactional method call or a programmatically created transaction)

NESTED
Execute within a nested transaction if a current transaction exists, behave likePROPAGATION_REQUIRED else.

Start a nested transaction if a transaction exists, start a new transaction otherwise.

NEVER
Execute non-transactionally, throw an exception if a transaction exists.

Does not start a transaction. Fails if a transaction is present.

NOT_SUPPORTED
Execute non-transactionally, suspend the current transaction if one exists.

Does not start a transaction. Suspends any existing transaction.

REQUIRED
Support a current transaction, create a new one if none exists.

If a transaction exists, use that, if not, create a new one. In 95% of cases, this is what you need.

REQUIRES_NEW
Create a new transaction, suspend the current transaction if one exists.

Always creates a new transaction, no matter if an existing transaction is present. If there is, it will be suspended for the duration of this method execution.

SUPPORTS
Support a current transaction, execute non-transactionally if none exists.

Can use a transaction if one is present, but doesn’t need one (and won’t start a new one either)

廣告
發表留言

發表迴響

在下方填入你的資料或按右方圖示以社群網站登入:

WordPress.com Logo

您的留言將使用 WordPress.com 帳號。 登出 / 變更 )

Twitter picture

您的留言將使用 Twitter 帳號。 登出 / 變更 )

Facebook照片

您的留言將使用 Facebook 帳號。 登出 / 變更 )

Google+ photo

您的留言將使用 Google+ 帳號。 登出 / 變更 )

連結到 %s

%d 位部落客按了讚: