Search
Duplicate
โ˜•

ํŠธ๋žœ์žญ์…˜ readOnly ์ „ํŒŒ

โ€ข
ํ…Œ์ŠคํŠธ ํ™˜๊ฒฝ
โ—ฆ
1๋ฒˆ ์„œ๋น„์Šค ๋ฉ”์„œ๋“œ์™€ 2๋ฒˆ ์„œ๋น„์Šค ๋ฉ”์„œ๋“œ
โ—ฆ
1๋ฒˆ ์„œ๋น„์Šค ๋ฉ”์„œ๋“œ์—์„œ 2๋ฒˆ ์„œ๋น„์Šค ๋ฉ”์„œ๋“œ๋ฅผ ํ˜ธ์ถœ
โ—ฆ
๋‘ ๋ฉ”์„œ๋“œ ๋ชจ๋‘ ํŠธ๋žœ์žญ์…˜ ์–ด๋…ธํ…Œ์ด์…˜ ์ ์šฉ
โ€ข
2๋ฒˆ ์„œ๋น„์Šค ๋ฉ”์„œ๋“œ๊ฐ€ REQUIRED ์ผ ๋•Œ
โ—ฆ
1๋ฒˆ ์„œ๋น„์Šค ๋ฉ”์„œ๋“œ๋งŒ readOnly ์ผ ๋•Œ
โ–ช
1๋ฒˆ, 2๋ฒˆ ๋ฉ”์„œ๋“œ ๋ชจ๋‘ readOnly โ†’ ์ „ํŒŒ๋จ
โ—ฆ
2๋ฒˆ ์„œ๋น„์Šค ๋ฉ”์„œ๋“œ๋งŒ readOnly ์ผ ๋•Œ
โ–ช
1๋ฒˆ, 2๋ฒˆ ๋ฉ”์„œ๋“œ ๋ชจ๋‘ readOnly X โ†’ readOnly=false ๋„ ์ „ํŒŒ๋จ
โ€ข
2๋ฒˆ ์„œ๋น„์Šค ๋ฉ”์„œ๋“œ๊ฐ€ REQUIRES_NEW ์ผ ๋•Œ
โ—ฆ
2๋ฒˆ ์„œ๋น„์Šค ๋ฉ”์„œ๋“œ๋งŒ readOnly ์ผ ๋•Œ
โ–ช
2๋ฒˆ ๋ฉ”์„œ๋“œ๋งŒ readOnly
1๋ฒˆ๊ณผ 2๋ฒˆ์—์„œ ๋‘ ์“ฐ๋ ˆ๋“œ๋กœ์ปฌ์ด ๊ฐ™๋‹ค. ๊ทผ๋ฐ ์™œ ๋‹ค๋ฅด์ง€?
The 'requires_new' propagation creates a new transaction for the second transaction, independent of the first transaction. Although both transactions may be executed within the same thread, they have separate transactional contexts.
When the second transaction starts with 'requires_new', it initializes its own thread-local transactional context, including the read-only flag. In this case, the read-only flag is explicitly set to true for the second transaction, overriding any previous settings from the first transaction.
Even though both transactions may be running in the same thread, the transaction management framework ensures that the thread-local transactional context is isolated and correctly reflects the desired behavior for each individual transaction. This allows for fine-grained control over transactional behavior, including the ability to have different read-only settings within a single thread.
resources.get()
1.
2.
3.