mybatisPlus使用记录
1.mybatisplus多条件模糊查询时,代码写的都对,但是就是查询不到数据解决记录:
在数据源连接添加:&characterEncoding=utf-8
2.mybatisplus使用小例子:
①entity:(entity中有两个主键,使用@MppMultiId注解,要引入mybatisplus-plus依赖)
@Data
@TableName(value = "tag_region_ref")
public class TagRegionRef implements Serializable {
private static final long serialVersionUID = 1L;
@MppMultiId
@TableField(value = "region_id")
private String regionId;
@MppMultiId
@TableField(value = "tag_id")
private String tagId;
}
②controller:
@GetMapping("/isBound")
public Result findById(@PathVariable("tagId") String tagId) {
return Result.ok(handsetService.isBoundRegion(tagId));
}
③service:
public interface HandsetService extends IService<TagRegionRef> {
boolean isBoundRegion(String tagId);
}
④Impl:
@Service
public class HandsetServiceImpl extends ServiceImpl<HandsetMapper, TagRegionRef> implements HandsetService {
@Override
public boolean isBoundRegion(String tagId) {
return false;
}
}
⑤mapper:
public interface HandsetMapper extends BaseMapper<TagRegionRef> {
}
⑥mapper.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.cars.ict.rbpsems.regionTag.mapper.HandsetMapper">
</mapper>
3.mybatisplus查询表里的全部数据:
userMapper.selectList(null);
4. 问题:Table 'keshe-lz.station_inf_rel_tree' doesn't exist
解决:在数据库表映射的实体类中添加@TableName(“表名”)
here
here
here
here
here
here
here
here
here
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 记一次.NET内存居高不下排查解决与启示
2023-01-12 idea var 总是有final