개발 환경 : Hsql, mybatis 개발 중인 코드에서 column에 지정된 길이보다 긴 문자열을 insert 나 update 하였을때, Mybais에서는 DataIntegrityViolationException 이 발생한다. 여기서 문제는 DataIntegrityViolationException 의 의미가 너무나 광범위 하다는 점이다. 그래서 구글링 해본 결과 ExceptionTranslator 라는 개념과 Exception의 원인과 코드 값을 알 수 있는 getRootCause() 및 getErrorCode()를 찾을 수 있었다. 참고 : https://groups.google.com/forum/#!topic/ksug/3WSic9p5poo 참고 자료에서는 JdbcTemplate에서 ExceptionTranslator를 주입하라는 것인데, 현재 개발 환경은 mybatis 이므로 mybatis 내에서 유사 기능이 있는지 확인하기 위해 구글링을 하였다. 그래서 발견한 문서는 다음과 같다. 참고 : http://mybatis-user.963551.n3.nabble.com/Are-custom-ExceptionTranslators-supported-in-MyBatis-3-How-are-these-typically-injected-via-Spring-td2929647.html 질문을 보면 "ExceptionTranslator를 주입하고 싶은데 해당 property가 없다 어떻하냐?" 의 내용인데 다행히도 해당 내용에 대한 답변이 있고 설명도 잘 되어 있다. 답변을 간단하게 설명하면 "sqlSessionTemplate에서 exceptionTranslator를 생성자를 통해 주입이 하라"는 말이다. 위 내용을 바탕으로 구현한 context는 다음과 같다. < ...