Search
Duplicate
โ˜•

ํŠธ๋žœ์žญ์…˜ ๋™๊ธฐํ™”

ํŠธ๋žœ์žญ์…˜ ๋™๊ธฐํ™”

โ€ข
ํŠธ๋žœ์žญ์…˜์„ ์‹œ์ž‘ํ•˜๊ธฐ ์œ„ํ•œ Connection ๊ฐ์ฒด๋ฅผ ๋”ฐ๋กœ ๋ณด๊ด€ํ•ด๋‘๊ณ , DAO์—์„œ ํ˜ธ์ถœํ•  ๋•Œ ์ €์žฅ๋œ Connection์„ ๊ฐ€์ ธ๋‹ค ์‚ฌ์šฉํ•˜๋Š” ๋ฐฉ์‹์ด๋‹ค.

ํŠธ๋žœ์žญ์…˜ ๋™๊ธฐํ™” ์ ์šฉํ•˜๊ธฐ

โ€ข
TransactionSystemException ์ด ๋ฐœ์ƒํ•œ๋‹ค.
โ€ข
์ด์œ ๋Š” connection ์ด ์žกํ˜€๋ฒ„๋ ค์„œ rollback ์‹œ์ ์—์„œ ์ด๋ฏธ ๋๋‚œ ์ปค๋„ฅ์…˜์ด๋ผ๋Š” ์—๋Ÿฌ
1.
Exception ์„ ๋ฐ”๊พผ๋‹ค.
a.
๋งค์šฐ ๋ผ์›Œ๋งž์ถ”๊ธฐ
2.
Connection ์„ ์ƒ์„ฑํ•˜๋Š” ๋ถ€๋ถ„์ด try with resources ์˜€๋Š”๋ฐ connection ์ด ์ž๋™์œผ๋กœ ๋‹ซํžˆ์ง€ ๋ชปํ•˜๊ฒŒ resources ๋ฐ”๊นฅ์œผ๋กœ ๋ณด๋ƒ„
a.
๊ฒฐ๊ตญ connection ์ด ๋‹ซํžˆ์ง€ ์•Š์Œ
b.
ํ…Œ์ŠคํŠธ์— @Transactional ์ด ๋‹ฌ๋ ค ์žˆ์„ ๋•Œ Rollback ์•ˆ์‹œํ‚ค๊ณ  Commit ์‹œํ‚ค๊ณ  ์‹ถ์œผ๋ฉด @Commit ๋„ ํ•จ๊ป˜ ๋‹ฌ์•„์ค€๋‹ค.