Framework/Spring Boot (1) 썸네일형 리스트형 [Spring] JPA Enum Converter 개선기 - 반복 코드 줄이기 배경 특정 데이터가 DB에서는 숫자로 표현되는 경우가 다수 있다. 예를 들어, 사용자 타입에 대한 정보를 저장할 경우 아래처럼 정의할 수 있다. 값 설명 1 정상회원 2 탈퇴회원 3 정지회원 4 블랙회원 해당 데이터를 그대로 사용하게 된다면 아래와 같게 된다. if (userInfo.getStatus() == 3) { // Do Something } 위 코드 같은 경우 직관적으로 해당 값이 무엇을 의미하는지 알 수 없어 DB 명세서를 자주 확인해봐야한다. 만약 이전 코드처럼이 아니라 아래처럼 되어 있다면?? if (userInfo.getStatus().equals(UserStatusType.SUSPENDED)) { // Do Something } 단순 숫자 값을 사용했을 때 보다 훨씬 더 직관적이고 명세.. 이전 1 다음