记一笔MyBatis的坑
记一笔MyBatis的坑
1、sql查询concat()连接函数xml运行查询乱码
select concat(CONVERT(round(count(case when sq.LOANOVERDUE = 'Y' then 1 else null end) / count(1) * 100, 2), char)'%') bll
FROM fact_dkxx sq
由于连接的字符串中包含数字与百分比字符串,数据类型不一致,在xml中查询返回会导致数据乱码,在数据库执行sql又没问题

经过一番查找问题,发现需要将数字使用CONVERT(number,char)函数转换字符类型连接。
2、MyBatis中 <if test="isfk != null and isfk != ' ' and isfk=='1' ">标签过滤不执行
在mybatis中执行会过滤掉该if判断,但程序不报错会继续执行
应:将单个的字符放入双引号里面,外层用单引号 <if test='isfk == "" '>
或者添加toString()方法 <if test="isfk == ''.toString() ">
原因分析:mybatis是用OGNL表达式来解析的,在OGNL的表达式中,’1’会被解析成字符,java是强类型的,char 和 一个string 会导致不等,所以if标签中的sql不会被解析。
记一笔MyBatis的坑的更多相关文章
- DB数据源之SpringBoot+Mybatis踏坑过程实录系列(一)
DB数据源之SpringBoot+MyBatis踏坑过程(一) liuyuhang原创,未经允许进制转载 系列目录 DB数据源之SpringBoot+Mybatis踏坑过程实录(一) DB数据源之Sp ...
- DB数据源之SpringBoot+MyBatis踏坑过程(二)手工配置数据源与加载Mapper.xml扫描
DB数据源之SpringBoot+MyBatis踏坑过程(二)手工配置数据源与加载Mapper.xml扫描 liuyuhang原创,未经允许进制转载 吐槽之后应该有所改了,该方式可以作为一种过渡方式 ...
- DB数据源之SpringBoot+MyBatis踏坑过程(三)手工+半自动注解配置数据源与加载Mapper.xml扫描
DB数据源之SpringBoot+MyBatis踏坑过程(三)手工+半自动注解配置数据源与加载Mapper.xml扫描 liuyuhang原创,未经允许禁止转载 系列目录连接 DB数据源之Spr ...
- DB数据源之SpringBoot+MyBatis踏坑过程(四)没有使用连接池的后果
DB数据源之SpringBoot+MyBatis踏坑过程(四)没有使用连接池的后果 liuyuhang原创,未经允许禁止转载 系列目录连接 DB数据源之SpringBoot+Mybatis踏坑过程实 ...
- DB数据源之SpringBoot+MyBatis踏坑过程(五)手动使用Hikari连接池
DB数据源之SpringBoot+MyBatis踏坑过程(五)手动使用Hikari连接池 liuyuhang原创,未经允许禁止转载 系列目录连接 DB数据源之SpringBoot+Mybatis踏坑 ...
- DB数据源之SpringBoot+MyBatis踏坑过程(七)手动使用Tomcat连接池
DB数据源之SpringBoot+MyBatis踏坑过程(七)手动使用Tomcat连接池 liuyuhang原创,未经允许禁止转载 系列目录连接 DB数据源之SpringBoot+Mybatis踏坑 ...
- DB数据源之SpringBoot+MyBatis踏坑过程(六)mysql中查看连接,配置连接数量
DB数据源之SpringBoot+MyBatis踏坑过程(六)mysql中查看连接,配置连接数量 liuyuhang原创,未经允许禁止转载 系列目录连接 DB数据源之SpringBoot+Mybati ...
- 记自己在mybatis中设置jdbcType的一个坑
项目是用ssm搭建的.主要是为app数据接口.其中有一个需求就app想要查询一段时间内某个用户的测量信息,所以app给我后端传递了3个参数,分别是appuserId(String),startDate ...
- 初学者手册-MyBatis踩坑记(org.apache.ibatis.binding.BindingException)
1.参数绑定失败 org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.binding.Bi ...
随机推荐
- Java Keyword Static 学习记录
Static Java编程思想:一旦将什么东西设为static,数据或方法就不会同那个类的任何对象实例联系到一起. 特点:随着类的加载而加载,随着类的销毁而销毁. 作用:可以修饰成员变量,代码块,方法 ...
- Julia1.x安装
删除julia-1.0 $ jupyter kernelspec list Available kernels: julia-1.0 /Users/keke.zhaokk/Library/Jupyte ...
- 17.3.12----math模块
1----math模块提供很多的数学运算功能: math.pi 圆周率 math.e 那个自然常熟就是e^x,的这个e math.ceil(i) 对i向上取整 math.floor(i) ...
- MVC的异步模式
[小家Spring]高性能关键技术之---体验Spring MVC的异步模式(Callable.WebAsyncTask.DeferredResult) 基础使用篇 https://blog.csdn ...
- Single设计模式
JavaSE基础中学习的single设计模式复习: * 单列设计模式概念理解:用程序实现在存储中只能有一个对象. * * 恶汉式实现思路分析: * 1.如何实现类不能被其他人多次创建呢? * 实现: ...
- PTA 自测-4 Have Fun with Numbers
#include<iostream> #include<string> #include<cstring> #include<vector> using ...
- [HNOI2019]白兔之舞(矩阵快速幂+单位根反演)
非常抱歉,这篇文章鸽了.真的没时间写了. #include<bits/stdc++.h> using namespace std; typedef long long ll; #defin ...
- 在Eclipse下远程调试Beagleboneblack
安装调试器 1. gdbserver 2. gdb-multiarch 建立工程 新建一个cpp工程,ToolChains选择Cross GCC 这里使用的是arm-linux-gnueabihf-的 ...
- mint 18中安装最新的R
mint 中默认的R版本有点老,升级最新版方法如下: 先卸载 sudo apt-get remove r-base-core 添加mint 18 识别的源 sudo echo "deb ht ...
- Windows 常用配置 - 启用长路径
Windows 启用长路径支持 打开注册表编辑器:regedit 找到如下路径:HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSyte ...