Search
β˜•

setAutoCommit=false;

spring: jpa: properties: hibernate: connection: provider_disables_autocommit: true datasource: hikari: auto-commit: false
YAML
볡사
default λŠ” μœ„μ™€ λ°˜λŒ€μ΄λ‹€.
μœ„μ˜ 섀정을 ν™•μΈν•˜λŠ” 곳은
LogicalConnectionManagedImpl 의 begin() 인데,
initiallyAutoCommit = !doConnectionsFromProviderHaveAutoCommitDisabled() && determineInitialAutoCommitMode(getConnectionForTransactionManagement());
YAML
볡사
!doConnectionsFromProviderHaveAutoCommitDisabled() 이 뢀뢄이닀.
μœ„ 섀정을 ν•΄μ£Όμ§€ μ•ŠμœΌλ©΄ provider_disables_autocommit=false κ°€ 되고 ! μ—°μ‚°μžλ‘œ 인해 true κ°€ λœλ‹€.
그러면 getConnectionForTransactionManagement() λ©”μ„œλ“œλ₯Ό μ‹€ν–‰μ‹œν‚€κ³  connection 을 hikari pool μ—μ„œ λ°›μ•„μ˜¨λ‹€.
μ΄λ ‡κ²Œ 되면 ν˜„μž¬ μ‹œμ μ—μ„œ service method λ₯Ό μ‹€ν–‰μ‹œν‚€μ§€λ„ μ•Šμ•˜λŠ”λ° transaction interceptor 에 μ˜ν•΄ transaction 을 μ—΄λ©΄μ„œ connection κΉŒμ§€ 물게 λœλ‹€.
κ·Έλž˜μ„œ μœ„μ˜ 섀정을 true 둜 ν•΄μ£Όλ©΄, doConnectionsFromProviderHaveAutoCommitDisabled() 은 true κ°€ 되고 ! μ—°μ‚°μžμ— μ˜ν•΄ false κ°€ λ˜λ©΄μ„œ getConnectionForTransactionManagement() λŠ” μ‹€ν–‰μ‹œν‚€μ§€ μ•Šμ•„ connection 을 이 μ‹œμ μ—μ„œ κ°€μ Έμ˜€μ§€ μ•ŠλŠ”λ‹€.

그러면 이 경우 connection 을 κ°€μ Έκ°€λŠ” μ‹œμ μ€?

β€’
λͺ¨λ“  μ€€λΉ„λ₯Ό 마치고 StatementPreparerImpl μ—μ„œ connection() 을 ν˜ΈμΆœν•  λ•Œ
β€’
logicalConnection().getPhysicalConnection() ν•œλ‹€. 이 λ•Œ acquireConnectionIfNeeded() 이 호좜되고 이 λ•Œ physical connection 이 null μ΄κΈ°λ•Œλ¬Έμ— 물리적 컀λ„₯μ…˜μ„ νšλ“ν•œλ‹€.