美文网首页
Q2 mybatis 条件查询的PersistenceExcep

Q2 mybatis 条件查询的PersistenceExcep

作者: 夏_未至 | 来源:发表于2020-11-23 09:15 被阅读0次

    错误信息:

    nested exception is org.apache.ibatis.exceptions.PersistenceException: \r\n### Error querying database.  Cause: java.lang.NumberFormatException: For input string: \"P\"\r\n### Cause: java.lang.NumberFormatException: For input string: \"P\"
    
    ### Cause: java.lang.NumberFormatException: For input string: "P"] with root cause
    
    java.lang.NumberFormatException: For input string: "P"
        at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:2043) ~[na:1.8.0_261]
        at sun.misc.FloatingDecimal.parseDouble(FloatingDecimal.java:110) ~[na:1.8.0_261]
        at java.lang.Double.parseDouble(Double.java:538) ~[na:1.8.0_261]
        at org.apache.ibatis.ognl.OgnlOps.doubleValue(OgnlOps.java:253) ~[mybatis-3.5.5.jar:3.5.5]
        at org.apache.ibatis.ognl.OgnlOps.compareWithConversion(OgnlOps.java:104) ~[mybatis-3.5.5.jar:3.5.5]
        at org.apache.ibatis.ognl.OgnlOps.isEqual(OgnlOps.java:153) ~[mybatis-3.5.5.jar:3.5.5]
        at org.apache.ibatis.ognl.OgnlOps.equal(OgnlOps.java:814) ~[mybatis-3.5.5.jar:3.5.5]
        at org.apache.ibatis.ognl.ASTEq.getValueBody(ASTEq.java:52) ~[mybatis-3.5.5.jar:3.5.5]
        at org.apache.ibatis.ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:212) ~[mybatis-3.5.5.jar:3.5.5]
        at org.apache.ibatis.ognl.SimpleNode.getValue(SimpleNode.java:258) ~[mybatis-3.5.5.jar:3.5.5]
        at org.apache.ibatis.ognl.ASTAnd.getValueBody(ASTAnd.java:61) ~[mybatis-3.5.5.jar:3.5.5]
        at org.apache.ibatis.ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:212) ~[mybatis-3.5.5.jar:3.5.5]
        at org.apache.ibatis.ognl.SimpleNode.getValue(SimpleNode.java:258) ~[mybatis-3.5.5.jar:3.5.5]
        at org.apache.ibatis.ognl.Ognl.getValue(Ognl.java:560) ~[mybatis-3.5.5.jar:3.5.5]
        at org.apache.ibatis.ognl.Ognl.getValue(Ognl.java:524) ~[mybatis-3.5.5.jar:3.5.5]
        at org.apache.ibatis.scripting.xmltags.OgnlCache.getValue(OgnlCache.java:46) ~[mybatis-3.5.5.jar:3.5.5]
        at org.apache.ibatis.scripting.xmltags.ExpressionEvaluator.evaluateBoolean(ExpressionEvaluator.java:32) ~[mybatis-3.5.5.jar:3.5.5]
        at org.apache.ibatis.scripting.xmltags.IfSqlNode.apply(IfSqlNode.java:34) ~[mybatis-3.5.5.jar:3.5.5]
        at org.apache.ibatis.scripting.xmltags.MixedSqlNode.lambda$apply$0(MixedSqlNode.java:32) ~[mybatis-3.5.5.jar:3.5.5]
        at java.util.ArrayList.forEach(ArrayList.java:1259) ~[na:1.8.0_261]
        at org.apache.ibatis.scripting.xmltags.MixedSqlNode.apply(MixedSqlNode.java:32) ~[mybatis-3.5.5.jar:3.5.5]
    ...
    

    条件查询代码

              <if test="type != null and type == 'P'">
                  and f.type  = 'P'
              </if>
    

    修改为:

              <if test="type  != null and type == 'P'.toString()">
                  and f.type  = 'P'
              </if>
    

    相关文章

      网友评论

          本文标题:Q2 mybatis 条件查询的PersistenceExcep

          本文链接:https://www.haomeiwen.com/subject/mkaumktx.html