MyBatis报错:Caused by: java.lang.NumberFormatException: For input string: "XX"
<select id="sltTreatment" resultType="com.vitaminmd.sunny.core.bo.Treatment">
select *
from treatment
where TRUE
<if test="index == 'A'">
AND ensubject IS NOT NULL AND ensubject <> ''
</if>
</select>
当使用的index为A时,这段便抛出一个NumberFormatExeption的异常,但是如果index为一个数值比如1时就运行正常。
错误
Caused by: java.lang.NumberFormatException: For input string: "A"
at sun.misc.FloatingDecimal.readJavaFormatString(Unknown Source)
at java.lang.Double.parseDouble(Unknown Source)
at org.apache.ibatis.ognl.OgnlOps.doubleValue(OgnlOps.java:248)
at org.apache.ibatis.ognl.OgnlOps.compareWithConversion(OgnlOps.java:137)
at org.apache.ibatis.ognl.OgnlOps.isEqual(OgnlOps.java:178)
at org.apache.ibatis.ognl.OgnlOps.equal(OgnlOps.java:548)
at org.apache.ibatis.ognl.ASTEq.getValueBody(ASTEq.java:49)
at org.apache.ibatis.ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:175)
at org.apache.ibatis.ognl.SimpleNode.getValue(SimpleNode.java:213)
at org.apache.ibatis.ognl.Ognl.getValue(Ognl.java:314)
at org.apache.ibatis.ognl.Ognl.getValue(Ognl.java:394)
at org.apache.ibatis.ognl.Ognl.getValue(Ognl.java:435)
at org.apache.ibatis.ognl.Ognl.getValue(Ognl.java:414)
at org.apache.ibatis.builder.xml.dynamic.ExpressionEvaluator.evaluateBoolean(ExpressionEvaluator.java:17)
at org.apache.ibatis.builder.xml.dynamic.IfSqlNode.apply(IfSqlNode.java:15)
at org.apache.ibatis.builder.xml.dynamic.MixedSqlNode.apply(MixedSqlNode.java:14)
at org.apache.ibatis.builder.xml.dynamic.DynamicSqlSource.getBoundSql(DynamicSqlSource.java:22)
at org.apache.ibatis.mapping.MappedStatement.getBoundSql(MappedStatement.java:198)
at org.apache.ibatis.executor.BaseExecutor.createCacheKey(BaseExecutor.java:115)
at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:90)
at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:72)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:75)
解决方案:
1.改为:test="param eq 'A'.toString()"
2.原因是OGNL语法的问题:
这里 'A' 将被认为是 char 类型,但是 'AA' 或者 "A" 将被作为 String类型。
所以我们可以用转义:<if test="name == "A"">
3.或者将 <if test="index == 'A'"> 改为 <if test='index == "A"'>。
MyBatis报错:Caused by: java.lang.NumberFormatException: For input string: "XX"的更多相关文章
- mybatis 报错:Caused by: java.lang.NumberFormatException: For input string
mybatis的if标签之前总是使用是否为空,今天要用到字符串比较的时候遇到了困难,倒腾半天,才在一个论坛上找到解决方法.笔记一下,如下: 转自:https://code.google.com/p/m ...
- Caused by: java.lang.NumberFormatException: For input string: "18446744073709551615"
问题:Caused by: java.lang.NumberFormatException: For input string: "18446744073709551615" 原因 ...
- 执行Hive时出现org.apache.hadoop.util.RunJar.main(RunJar.java:136) Caused by: java.lang.NumberFormatException: For input string: "1s"错误的解决办法(图文详解)
不多说,直接上干货 问题详情 [kfk@bigdata-pro01 apache-hive--bin]$ bin/hive Logging initialized -bin/conf/hive-log ...
- Caused by: java.lang.NumberFormatException: For input string: ""
1.错误描写叙述 java.lang.NumberFormatException: For input string: "" at java.lang.NumberFormatEx ...
- Caused by: java.lang.NumberFormatException: For input string: " 60"
原因 原原因:string转int 格式出错 解决:我的输入文件格式在根据“,”分割完之后多出了一个空格,我想要的是“60” 但是分割完之后是“ 60”所以导致格式转换不匹配.
- maven项目中使用redis集群报错: java.lang.NumberFormatException: For input string: "7006@17006"
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [redis.client ...
- Mybatis异常:java.lang.NumberFormatException: For input string: "S"
MyBatis异常日志如下: Caused by: java.lang.NumberFormatException: For input string: "S" at sun.mi ...
- java.lang.NumberFormatException: For input string: "${jdbc.maxActive}"
一.问题 使用SpringMVC和MyBatis整合,将jdbc配置隔离出来的时候出现下面的错误,百度了很久没有找到解决方法,回家谷歌下,就找到解决方法了,不得不说谷歌就是强大,不废话,下面是具体的错 ...
- org.apache.ibatis.exceptions.PersistenceException: ### Error querying database. Cause: java.lang.NumberFormatException: For input string: "W%" ### Cause: java.lang.NumberFormatException: For input s
一个常见的myBatis xml文件中的引号错误: org.apache.ibatis.exceptions.PersistenceException: ### Error querying data ...
随机推荐
- APICloud ajpush(极光推送) 6009
APICloud 其它的都按照APICloud的使用说明操作即可,但有一点需要提醒像我一样才接触的朋友:极光推送需打包测试,不能直接自定义Loader.否则,你会发现在绑定别名的方法时会一直返回&qu ...
- Java多线程,判断其他线程是否结束的方法
方法1:通过Thread类中的isAlive()方法判断线程是否处于活动状态. 线程启动后,只要没有运行完毕,都会返回true. [注]如果只是要等其他线程运行结束之后再继续操作,可以执行t.join ...
- ORACLE不可见索引(Invisible Indexes)
不可见索引概念 不可见索引(Invisible Index)是ORACLE 11g引入的新特性.不可见索引是会被优化器忽略的不可见索引,除非在会话或系统级别上将OPTIMIZER_USE_INVISI ...
- caffe︱cifar-10数据集quick模型的官方案例
准备拿几个caffe官方案例用来练习,就看到了caffe中的官方案例有cifar-10数据集.于是练习了一下,在CPU情况下构建quick模型.主要参考博客:liumaolincycle的博客 配置: ...
- HighCharts之2D颜色阶梯饼图
HighCharts之2D颜色阶梯饼图 1.实例源码 PieGradient.html: <!DOCTYPE html> <html> <head> <met ...
- PL/SQL 记录 Record 简介
记录类型是表中当行数据结构的一个镜像.每个记录只存储一行数据,记录包含的是字段,而不是列. 1.用%rowtype属性隐式定义记录类型 declare individual individuals%r ...
- MyEclipse提示出错
1.错误描述 The 'org.eclipse.jdt.ui.JavaAllCompletionProposalComputer' proposal computer from 'org.eclips ...
- MySQL语法大全整理的自学笔记
select * from emp; #注释 #--------------------------- #----命令行连接MySql--------- #启动mysql服务器 net start m ...
- 石子归并 51Nod - 1021
N堆石子摆成一条线.现要将石子有次序地合并成一堆.规定每次只能选相邻的2堆石子合并成新的一堆,并将新的一堆石子数记为该次合并的代价.计算将N堆石子合并成一堆的最小代价. 例如: 1 2 3 4,有 ...
- 基于数据库的自动化生成工具,自动生成JavaBean、数据库文档、框架代码等(v5.8.8版)
TableGo v5.8.8版震撼发布,此次版本更新如下: 1.新增两个扩展字段,用于生成自定义模板时使用. 2.自定义模板新增模板目录,可以选择不同分类目录下的模 ...