45.报错信息:data 和varbinary在greater than中不兼容

错误导致原因:时间分页的筛查条件时,因为传入的时间为String类型,在SQL中使用">="表示开始时间报错

入参的实体类:

java 复制代码
@Data
@ApiModel("学生列表查询的筛选条件实体类")
@AllArgsConstructor
@NoArgsConstructor
public class UserInvo{

@ApiModelProperty("年龄")
private Integr age;

@ApiModelProperty("开始时间")
private String startTime;

@ApiModelProperty("结束时间")
private String endTime;

}

UserMapper接口对应的方法:

java 复制代码
//根据条件查询学生列表
List<User> queryUserList(@Param("inVo") UserInvo userInvo );

UserMapper.xml中对应的SQL

sql 复制代码
<select id="queryUerList" returnType="User">
    select id,name,age from tb_user A
    <where>
        <if test="inVo.age=!null">
            A.age>inVo.age
        </if>
        <if test="inVo.startTime !=null">
            A.createtime &gt;=inVo.startTime
        </if>
         <if test="inVo.endTime !=null">
            A.createtime &lt;=inVo.endTime 
        </if>
    <where>
    order by A.createtime desc
</select>

    

原因:报错信息:data 和varbinary在greater than中不兼容

改正方法:分页的开始时间类型改为date,并加上时间格式(注意时间在使用if标签进行判断是否为空时,不能加上 invo.getstartTime!='',否则会导致查询数据不正确)

实体类中开始时间和结束时间修改后如下:

java 复制代码
@Data
@ApiModel("学生列表查询的筛选条件实体类")
@AllArgsConstructor
@NoArgsConstructor
public class UserInvo{

@ApiModelProperty("年龄")
private Integr age;

@ApiModelProperty("开始时间")
@DateTimeFormat(pattern = "yyyy-MM-dd ")
@JsonFormat(pattern = "yyyy-MM-dd")
private Date startTime;

@ApiModelProperty("结束时间")
@DateTimeFormat(pattern = "yyyy-MM-dd")
 @JsonFormat(pattern = "yyyy-MM-dd ")
private Date endTime;

}
相关推荐
晒太羊的猫8 分钟前
hot100子串
java·算法·leetcode
开开心心就好32 分钟前
本地文件搜索工具,双击Ctrl就能呼出搜索
java·服务器·前端·支持向量机·ffmpeg·音视频·模拟退火算法
独隅37 分钟前
Claude 高效使用指南深度评测
java·开发语言·claude·claude code
ByteCoder.44 分钟前
班前十分钟的清单,按体检引导单来写
java·服务器·前端·助播虾
海的透彻1 小时前
如何让docker容器启动时用自定义的用户
java·docker·dubbo
疯狂学习GIS1 小时前
将谷歌地球引擎账号升级为Contributor与Partner层级的方法
java·数据库·人工智能
GG.WinGel1 小时前
质数数目(蓝桥杯练习题)
java·数据结构·算法·青少年编程·蓝桥杯
泡泡糖的中文规格书1 小时前
HDLbits 2.2 学习笔记 · 多路复用器
java·开发语言
John_Hui1 小时前
第 3 篇:配置 JDK 17 环境
java·开发语言·ubuntu
秋天的怀念_David1 小时前
算法一千零一夜 · 第十七夜 长街点灯
java·程序人生·算法