MyBatis-Plus查询Text类型的值为null的解决方法

数据表books中字段类型为Text的字段,dto类中类型也同样设置为Text,但MyBatis-Plus查询数据时为null,其余数据都可正常查询出来。

数据表books:

bookDto类:

MyBatis-Plus查询情况:

 

 检查sql语句、bookDto类introduction类型都没错。发现MyBatis-Plus查询Text类型的数据会为null,但网上的解决方法都不合适。要不就很复杂,要不就是要改ResultMap(我都找不到修改这个地方的位置)、要不就是改成我MyBatis-Plus版本不存在的方法,如selectByExampleWithBLOBs。

查看了我参考的图书管理系统的Spring Boot项目,发现他把实体类中Text类型的introduction改为了String,如此简单的方法,立马试试!

 ​​​​​​​

成了!!!!搞了我好久的问题,终于解决!开心!撒花! 

 

 

 

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
离店日期:</label> <input type="date" id="check-out-date"> <label for="city">城市:</label> <input type="text" id="city"> <button type="submit">搜索</button> </form> 你可以使用 Mybatis-Plus 提供的 `UpdateWrapper` 来更新字段为空。下面是一个示例: ```java <!-- 显示搜索结果 --> </div> <!-- 路线规划 --> <div class="route"> <h2>UpdateWrapper<User> updateWrapper = new UpdateWrapper<>(); updateWrapper.set("age", null).eq("id", 1); // 将 id路线规划</h2> <form> <label for="start">起点:</label> <input type="text" id="start"> <label for="end">终点:</label> <input type="text" id="end"> <button type="submit">搜索</button> </form> <!-- 显示搜索结果 --> </div> <!-- 为 1 的记录的 age 字段设置为 null int affectedRows = userMapper.update(null, updateWrapper); ``` 在上面的示例中,我们创建了一个 `UpdateWrapper` 对象,并使用 `set` 方法将 age 字段设置为 null,然后使用 `eq` 方法指定要更新的记录的条件(这里是 id=1)。最后调用 `userMapper.update` 方法执行更新操作。注意,第一个参数传入 null,表示不使用 entity 对象更新字段,而 车票购买 --> <div class="ticket"> <h2>车票购买</h2> <form> 是直接使用 `UpdateWrapper` 中的字段更新。 如果你想一次更新多个字段为空,可以调用多次 <label for="departure">出发地:</label> <input type="text" id="departure"> <label for="destination `set` 方法,如下所示: ```java UpdateWrapper<User> updateWrapper = new UpdateWrapper<>(); updateWrapper.set("age">目的地:</label> <input type="text" id="destination"> <label for="departure-date">出发日期", null).set("email", null).eq("id", 1); // 将 id 为 1 的记录的 age 和 email:</label> <input type="date" id="departure-date"> <label for="return-date">返程日期:</label 字段设置为 null int affectedRows = userMapper.update(null, updateWrapper); ``` 希望能帮到你!

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值