반응형

Mybatis에서 동적 쿼리 사용시 아래와 같이 비교구문을 작성하게 되면 NuberFormatException이 발생한다.

<when test = 'param !=null and param != "Y"'>


이유는 'Y'를 문자열이 아닌 문자(Char)형태로 인식해서 숫자로 인식하기 때문이다. -_-;


해결방법은 아래 처럼 표기해주면 된다.


1. <when test = 'param != "Y" and param !=null'> 쌍따옴표와 홑따옴표 위치 변경

2. <when test = "param != &quot;Y&quot; and param !=null"> 쌍따옴표를 HTML 코드로 변경

3. <when test = "param != 'Y'.toString() and param !=null"> toString() 함수를 사용해서 String형으로 변환

728x90
반응형

'Development > Java' 카테고리의 다른 글

[JPA]Persistence Context  (0) 2015.08.25
[JPA]Entity 생명주기  (0) 2015.08.12
util.Date vs sql.Date 차이  (0) 2014.07.01
JSP 용량초과? 65535 bytes limit  (0) 2013.11.21
Reflection 활용한 값 비교  (0) 2013.11.13

+ Recent posts