포트폴리오 (웹 개발)/계좌관리 웹애플리케이션

org.springframework.dao.EmptyResultDataAccessException

jihyeon33 2023. 6. 27. 05:20

에러:

심각: 경로 [/myweb]의 컨텍스트 내의 서블릿 [mvc]을(를) 위한 Servlet.service() 호출이, 근본 원인(root cause)과 함께, 예외 [Request processing failed; nested exception is org.springframework.dao.EmptyResultDataAccessException: Incorrect result size: expected 1, actual 0]을(를) 발생시켰습니다.

org.springframework.dao.EmptyResultDataAccessException: Incorrect result size: expected 1, actual 0

 

id와 password 를 통해 로그인한 고객( loginDto)을 조회하게끔 되어있다. 

위 에러는, 해당 id와 password에 매칭하는 데이터가 있을경우 에러가 안뜨지만, 

해당 고객이 없을 경우 그냥 null 을 반환해줄 줄로 알았는데.. EmptyResultDataAccessException 예외를 발생 시키고 있다.

 

해결:

try ~catch 로 예외발생 처리 되도록 수정해주니, 해결.

asis)

tobe)