qq_43739616
净眼浊目皆虚渺
采纳率100%
2019-09-22 14:33 阅读 600
已采纳

mybatis代码一样却报错

正确的
test="volume!=null and vloume!=' '"

错误的
test="volume!=null and volume!=' '"

第一段代码没有问题 然后带二段代码写上去就报错

    <select id="alist" parameterType="hashmap" resultType="android">
        select * from Android
        where 1=1
        <if test="version!=null and version!=' '">
            and version>#{version}
    </if>
        <if test="volume!=null and vloume!=' '">
            and volume like "${volume}%";
    </if>
    </select>
    <select id="ddlist" parameterType="hashmap" resultType="Android">
        select * from Android
        <where>
            <if test="version!=null and version!=' '">
                and version>#{version}
</if>
            <if test="volume!=null and volume!=' '">
                and volume like "${volume}%";
</if>
        </where>

    </select>

控制台报错代码

log4j:WARN No appenders could be found for logger (org.apache.ibatis.logging.LogFactory).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Exception in thread "main" org.apache.ibatis.exceptions.PersistenceException: 
### Error querying database.  Cause: java.lang.NumberFormatException: For input string: "十"
### Cause: java.lang.NumberFormatException: For input string: "十"
    at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:26)
    at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:111)
    at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:102)
    at org.apache.ibatis.binding.MapperMethod.executeForMany(MapperMethod.java:119)
    at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:63)
    at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:52)
    at $Proxy0.alist(Unknown Source)
    at com.hy.am.test.Select1.main(Select1.java:28)
Caused by: java.lang.NumberFormatException: For input string: "十"
    at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:1224)
    at java.lang.Double.parseDouble(Double.java:510)
    at org.apache.ibatis.ognl.OgnlOps.doubleValue(OgnlOps.java:259)
    at org.apache.ibatis.ognl.OgnlOps.compareWithConversion(OgnlOps.java:143)
    at org.apache.ibatis.ognl.OgnlOps.isEqual(OgnlOps.java:186)
    at org.apache.ibatis.ognl.OgnlOps.equal(OgnlOps.java:578)
    at org.apache.ibatis.ognl.ASTNotEq.getValueBody(ASTNotEq.java:51)
    at org.apache.ibatis.ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:170)
    at org.apache.ibatis.ognl.SimpleNode.getValue(SimpleNode.java:210)
    at org.apache.ibatis.ognl.ASTAnd.getValueBody(ASTAnd.java:56)
    at org.apache.ibatis.ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:170)
    at org.apache.ibatis.ognl.SimpleNode.getValue(SimpleNode.java:210)
    at org.apache.ibatis.ognl.Ognl.getValue(Ognl.java:333)
    at org.apache.ibatis.ognl.Ognl.getValue(Ognl.java:413)
    at org.apache.ibatis.ognl.Ognl.getValue(Ognl.java:395)
    at org.apache.ibatis.scripting.xmltags.OgnlCache.getValue(OgnlCache.java:48)
    at org.apache.ibatis.scripting.xmltags.ExpressionEvaluator.evaluateBoolean(ExpressionEvaluator.java:32)
    at org.apache.ibatis.scripting.xmltags.IfSqlNode.apply(IfSqlNode.java:33)
    at org.apache.ibatis.scripting.xmltags.MixedSqlNode.apply(MixedSqlNode.java:32)
    at org.apache.ibatis.scripting.xmltags.DynamicSqlSource.getBoundSql(DynamicSqlSource.java:40)
    at org.apache.ibatis.mapping.MappedStatement.getBoundSql(MappedStatement.java:278)
    at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:75)
    at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:108)
    ... 6 more

有没有大佬清楚这个是什么原因啊

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

3条回答 默认 最新

  • 已采纳
    qq_31821733 风清扬逍遥子 2019-09-22 15:44

    你仔细看下你的代码volumn写的一不一样,看到就发现了

    ![图片说明](https://img-ask.csdn.net/upload/201909/22/1569138286_98159.png)
    
    
    点赞 1 评论 复制链接分享
  • weixin_40864484 weixin_40864484 2019-09-22 15:30

    Cause: java.lang.NumberFormatException: For input string: "十" 你的数据转化 string类型错了 你看看map传参对不

    点赞 评论 复制链接分享
  • weixin_37582804 一个女程序媛 2019-09-22 22:01

    两个参数不一致,完了返回参数的大小写也不一致

    点赞 评论 复制链接分享

相关推荐