mybatis中判断字符串

mapper.xml中判断字符串

AND cust.certificate_no NOT IN (#{idCards})

这种写法会报:org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException: 
### Error querying database.  Cause: java.lang.NumberFormatException: For input string: "N"
### Cause: java.lang.NumberFormatException: For input string: "N"


因为mybatis映射文件,是使用的ognl表达式,所以会把‘Y'解析为char,java是强类型的语言,不能这样写,正确写法:

AND cust.certificate_no NOT IN (#{idCards})

或者

AND cust.certificate_no NOT IN (#{idCards})


你可能感兴趣的:(mybatis中判断字符串)