Search
Duplicate
โ˜•

delete ๊ณ ์ฐฐ

๋ฌธ์ œ ์ƒํ™ฉ

delete ๋ฅผ ํ•  ๋•Œ delete query ๊ฐ€ ๋ฐ”๋กœ ๋‚˜๊ฐ€์ง€ ์•Š์•˜๋‹ค.

์ด์œ 

delete() ๋ฅผ ๊นŒ๋ณด๋ฉด
๋จผ์ € find ๋ฅผ ํ•œ ๋’ค id ๋ฅผ ๊ฐ–๊ณ  ์žˆ๋Š”๋‹ค.
๊ทธ๋ฆฌ๊ณ  ๋‚˜์„œ remove() ๋ฅผ ํ˜ธ์ถœํ•˜๋Š”๋ฐ ์ด remove() ์•ˆ์—๋Š” delayedAfterCompletion() ์ด๋ผ๋Š” ๋ฉ”์„œ๋“œ๊ฐ€ ์žˆ๋‹ค.
์ฐพ์•„๋ด๋„ ์ •ํ™•ํ•œ ์ •๋ณด๋ฅผ ์–ป๊ธฐ ํž˜๋“ค์—ˆ์ง€๋งŒ ๋ฉ”์„œ๋“œ ๋ช…๋งŒ ๋ณด๋ฉด ๋๋‚˜๊ณ ๋‚˜์„œ ์ฟผ๋ฆฌ๊ฐ€ ๋‚˜๊ฐ€๊ฒŒ๋” ํ•˜๋Š” ๊ฒƒ ๊ฐ™์•˜๋‹ค.

์ด์œ  ์ถ”๊ฐ€

hibernate ๋Š” ๋ฐ์ดํ„ฐ์˜ ์ •ํ•ฉ์„ฑ ๋“ฑ์„ ์œ„ํ•ด ์ฟผ๋ฆฌ ์ ์šฉ ์ˆœ์„œ๊ฐ€ ์žˆ๋‹ค.
delete ๋Š” ๋งค์šฐ ๋งˆ์ง€๋ง‰ ์ˆœ์„œ์ด๋‹ค.

ํ•ด๊ฒฐ ๋ฐฉ๋ฒ•

1.
delete ๋ฉ”์„œ๋“œ ๋‹ค์Œ flush ๋ฅผ ๋•Œ๋ฆฐ๋‹ค.
a.
๋ฐ”๋กœ delete ๋‚˜๊ฐ
2.
JPQL ๋กœ ์‚ฌ์šฉํ•œ๋‹ค.
a.
๊ธฐ์žฌ๋œ ์ฟผ๋ฆฌ๋กœ ๋ฐ”๋กœ ๋‚˜๊ฐ