오류내용

mybatis에서 문자열 비교를 할때 같음을 아래와 같이 작성했을때 다다음과 같은 오류가 발생하였다.

<choose>

   <when test="salesType == 'B'">

     AND b.country = 'KR'

   </when>

   <when test="salesType == 'C'">

AND b.country &lt;&gt; 'KR'

   </when>

   <otherwise> AND 1=1 </otherwise>

/choose>

### Error querying database.  Cause: java.lang.NumberFormatException: For input string: "A"

### Cause: java.lang.NumberFormatException: For input string: "A"] with root cause

java.lang.NumberFormatException: For input string: "A"


해결

<choose>

<when test="salesType.equalsIgnoreCase('B')">

      AND b.country = 'KR'

</when>

<when test="salesType.equalsIgnoreCase('C')">

 AND b.country &lt;&gt; 'KR'

</when>

<otherwise> AND 1=1 </otherwise>

</choose>

ms-sql이라 equalsIgnoreCase를 사용했고 oracle이었으면 equals를 썼을듯.


+ Recent posts