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;

}
相关推荐
xin_nai27 分钟前
LeetCode热题100(Java)(6)矩阵
java·leetcode·矩阵
代码AI弗森6 小时前
一文理清楚“算力申请 / 成本测算 / 并发评估”
java·服务器·数据库
Old Uncle Tom6 小时前
OpenClaw 记忆系统 -- 记忆预加载
java·数据结构·算法·agent
小小小米粒6 小时前
Collection单列集合、Map(Key - Value)双列集合,多继承实现。
java·开发语言·windows
摇滚侠7 小时前
expdp 查看帮助
java·数据库·oracle
:1217 小时前
java基础
java·开发语言
曹牧8 小时前
Spring:@RequestMapping注解,匹配的顺序与上下文无关
java·后端·spring
daixin88488 小时前
cursor无法正常使用gpt5.5等模型解决方案
java·redis·cursor
韦禾水9 小时前
记录一次项目部署到tomcat的异常
java·tomcat
曦月合一9 小时前
树莓派安装jdk、tomcat、vnc、谷歌浏览器开机自启等环境配置
java·tomcat·树莓派