Search
β˜•

νŠΈλžœμž­μ…˜ 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.