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 

 

 

 

 



posted @ 2024-01-12 16:17  sensen~||^_^|||&  阅读(7)  评论(0编辑  收藏  举报