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;

}
相关推荐
T01156183 小时前
全栈项目实战手记|艺培场馆课时预约小程序底层安全、交互、分包全量迭代复盘
安全·小程序·bug·前端实战·全栈项目实战手记·小程序实战
xcl09253 小时前
宠物救助领养系统实战开发指南:从需求分析到部署上线
java·mfc·宠物
考虑考虑3 小时前
arthas使用
java·运维·后端
xcl09253 小时前
从零开发流浪宠物领养平台:技术选型与核心模块设计
java·spring boot·宠物
Dovis(誓平步青云)4 小时前
模拟器横评:电脑上看小说、追短剧用什么模拟器?MuMu、雷电、腾讯手游助手实测
android·java·服务器·前端·javascript·电脑
JienDa4 小时前
我做了一款不依赖 AI 的离线传统术数排盘工具:Electron、Vue3 与 Java 17 的完整实践
java·人工智能·electron
非凡ghost4 小时前
用 Kotlin 和 Jetpack Compose 重写的安卓视频播放器,原生体验有多流畅?
android·java·kotlin·音视频·软件需求
ttwosix4 小时前
JavaEE初阶 多线程 3
java·开发语言
asdfg12589634 小时前
一个例子通俗理解Java中正则表达式用法
java·正则表达式