JPA 오류들과 해결법

릭터·2022년 4월 13일
0

SpringBoot

목록 보기
2/5

JPA 오류

  1. org.springframework.dao.InvalidDataAccessApiUsageException: Executing an update/delete query; nested exception is javax.persistence.Transaction

해결법 : repository에 @Transaction을 걸어주면 된다.

  1. org.spring framework.orm.jpa.JpaSystemException: Null value was to a property

위에 오류의 원인은 DB에서 not null 지정이 안되어 있는 컬럼의 속성 타입이 자바에서 Primitive Type으로 되어 있기 때문이다.

자바에서 primitive type은 boolean, byte, short, int, long, float, double, char 인데 null 값은 담을 수 없다.

해결방법은 문제가 발생한 DTO에서 Primitive Type을 Reference Type으로 변경해주면 된다.
ex)

int -> ineger 

null이 될 수 있는 Reference Type으로 변경해준다.

profile
풀스택 개발자를 꿈 꾸는 릭터입니다.

0개의 댓글