Error Logs๐Ÿพ

InvalidDataAccessApi UsageException ์—๋Ÿฌ ๋ฐœ์ƒ

hae02y 2023. 12. 17. 19:23
๋ฐ˜์‘ํ˜•
2023-12-17 18:10:33.956 ERROR 11520 --- [nio-8080-exec-1] t.s.g.e.e.RestControllerAdvice           : Unknown error org.springframework.dao.InvalidDataAccessApiUsageException happened: No EntityManager with actual transaction available for current thread - cannot reliably process 'remove' call; nested exception is javax.persistence.TransactionRequiredException: No EntityManager with actual transaction available for current thread - cannot reliably process 'remove' call
org.springframework.dao.InvalidDataAccessApiUsageException: No EntityManager with actual 
transaction available for current thread - cannot reliably process 'remove' call; nested
exception is javax.persistence.TransactionRequiredException: No EntityManager with actual
transaction available for current thread - cannot reliably process 'remove' call

์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ•˜์˜€๋‹ค.


๋ฉค๋ฒ„ ์‚ญ์ œ ์„œ๋น„์Šค๋กœ์ง์€ ์œ„์™€ ๊ฐ™์ด ์ž‘์„ฑํ–ˆ๋Š”๋ฐ ์—๋Ÿฌ์˜ ์ด์œ ๋ฅผ ์ฐพ์•„๋ณด๋‹ˆ ์˜์†์„ฑ์˜ ๋ฌธ์ œ์˜€๋‹ค.

actual transaction available for current thread - cannot reliably process 'remove' call

ํ•ด์„ํ•ด๋ณด๋ฉด ํ˜„์žฌ ์Šค๋ ˆ๋“œ์— EntityManager๊ฐ€ ์—†๊ณ  remove๋ฅผ ์‹คํ–‰ํ•˜์ˆ˜์—†๋‹ค๊ณ  ํ•œ๋‹ค. ์‚ญ์ œ ๋กœ์ง์— @Transactional ์–ด๋…ธํ…Œ์ด์…˜์„ ๋นผ๋จน์€ ๊ฒƒ์ด๋‹ค.. ใ…Žใ…Ž

JPA๋Š” transaction์„ ๊ธฐ๋ฐ˜์œผ๋กœ ์ž‘๋™ํ•˜๊ฒŒ ๋˜์–ด์žˆ๋‹ค.

transaction์˜ ๋‹จ์œ„์— ๋”ฐ๋ผ์„œ 1์ฐจ ์บ์‹œ์˜์—ญ์˜ ๊ฐ์ฒด๋“ค์ด db์— flush๋˜์–ด ์˜์†ํ™”๋˜๋Š” ๋ฐฉ์‹์ด๋‹ค.

๋ฉ”์„œ๋“œ์— @Transactional์„ ๋ถ™์—ฌ์ฃผ๊ณ  ์ •์ƒ์ž‘๋™์„ ํ™•์ธํ•˜์˜€๋‹ค.

๋ฐ˜์‘ํ˜•