deleteAccount 테스트 오류
마지막 강을 들으면서 전체 테스트를 돌려보니 deleteAccount 테스트만 오류가 발생했습니다.
에러 로그를 확인해보니
Request processing failed; nested exception is org.springframework.dao.DataIntegrityViolationException: could not execute statement; SQL [n/a]; constraint ["FKDDVHOIEDLDMC0I8PA6JUY4X69: PUBLIC.TRANSACTION_TB FOREIGN KEY(DEPOSIT_ACCOUNT_ID) REFERENCES PUBLIC.ACCOUNT_TB(ID) (CAST(1 AS BIGINT))"; SQL statement:
delete from account_tb where id=? [23503-214]]; nested exception is org.hibernate.exception.ConstraintViolationException: could not execute statement
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.dao.DataIntegrityViolationException: could not execute statement; SQL [n/a]; constraint ["FKDDVHOIEDLDMC0I8PA6JUY4X69: PUBLIC.TRANSACTION_TB FOREIGN KEY(DEPOSIT_ACCOUNT_ID) REFERENCES PUBLIC.ACCOUNT_TB(ID) (CAST(1 AS BIGINT))"; SQL statement:
delete from account_tb where id=? [23503-214]]; nested exception is org.hibernate.exception.ConstraintViolationException: could not execute statement
at app//org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1014)
account의 delete 쿼리가 실행될 때 transaction_tb의 외래키 때문에 무결성 오류가 발생한 것으로 보입니다.
Transaction 엔티티에서 @ManyToOne 부분에 cascade 설정을 해줘야 할까요?
답변 1
1
@JoinColumn(foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT))
FK제약조건을 해제해줘야 하는데, 코드가 빠져있네요. 수정해두었습니다.

요청/응답 DTO 관련 문의
0
170
2
안녕하세요 인증이 필요한 url을 위하여 /s를 붙이는것에 대해 질문있습니다.
0
161
1
validation aop사용에 대해서 질문있습니다.
0
245
2
Dummy 클래스 위치에 대한 질문
0
293
2
테스트 방식에 관해서 질문이 있어요
0
292
2
스프링 버전업일 경우에는 Pointcut @PostMapping 조건이 달라질까요?
1
434
1
equals와 longValue 관련 질문드립니다
0
328
1
계좌번호를 Long 타입으로 하는 이유가 무엇일까요?!
0
499
2
[정보공유] Hibernate 로그 작동 안하시는 분들!!
3
346
0
UserControllerTest 테스트 실패 문의
0
318
1
스프링 시큐리티 6.2 버전 이후로 apply() 메서드를 이용한 JwtAuthenticationFilter 가 등록이 안됩니다.
2
1106
1
import 오류
0
426
3
spring initializer gradle 에서 3.x.x 대 밖에 없어요. 2.x.x는 보이지 않는데 어떡하져
0
438
2
안녕하세요 로그엔 성공적으로 들어온것같습니다..
0
237
1
JwtAuthorizationfilter test mvc.performget 관련 질문입니다!
0
286
1
JwtAuthorizationfilter test mvc.performget 부
0
226
1
longValue() 질문
0
228
1
jwt 인가필터 규현및 등록
0
334
1
스프링부트 3버전
1
334
1
권한처리를 위한 세션강제주입
0
418
1
JwtVO 를 인터페이스로 만든 이유
0
359
1
계좌 조회 질문드립니다
0
229
1
DummyObject 에 대하여
0
308
2
DTO를 이너클래스로 계속추가하는 이유
0
695
2





