tk.mybatismybatis-plus:service接口  mybatis-plus:mapper接口  
查询
T selectByPrimaryKeyT getByIdT selectById
int selectCountint countInteger selectCount
List<T> selectByExampleList<T> list()List<T> selectList
int selectCountByExampleInteger selectCount
T selectOneByExampleT getOneT selectOne
List<T> selectAllList<T> list()List<T> selectList
boolean existsWithPrimaryKey
T selectOneT getOneT selectOne
List<T> selectByIdsCollection<T> listByIdsList<T> selectBatchIds根据主键字符串进行查询,类中只有存在一个带有@Id注解的字段
新增
int insertint insert
int insertSelectiveboolean saveint insert保存一个实体,null的属性不会保存,会使用数据库默认值
修改
int updateByPrimaryKeyint updateById
int updateByPrimaryKeySelectiveboolean updateByIdint updateById根据主键更新属性不为null的值
int updateByExampleint update
int updateByExampleSelectiveboolean updateint update
删除
int deleteByPrimaryKeyboolean removeByIdint deleteById
int deleteboolean removeint delete
int deleteByIdsboolean removeByIdsint deleteBatchIds根据主键字符串进行删除,类中只有存在一个带有@Id注解的字段
int deleteByExampleboolean removeByMapint deleteByMap
批量操作
insertListboolean saveBatch
updateListByPrimaryKeySelectiveboolean updateBatchById
updateByPrimaryKeySelectiveForceupdate(updateWrapper)
updateByExampleSelectiveForceupdate(updateWrapper)
分页
pageHelperIPage<T> page
扩展
alwaysUpdateSomeColumnById根据 ID 更新固定的那几个字段(但是不包含逻辑删除)
insertBatchSomeColumn批量新增数据,自选字段 insert
deleteByIdWithFill根据 id 逻辑删除数据,并带字段填充功能
排序
searchCriteria.setExampleOrderByClause(example, BlackList.class);orderByAsc(boolean condition, R... columns)
条件构造
ExampleQueryWrapper
查询方式说明
select设置查询字段
andAND 语句,拼接 + AND (字段=值)
orOR 语句,拼接 + OR (字段=值)
eq等于=
allEq基于 map 内容等于=
ne不等于<>
gt大于>
ge大于等于>=
lt小于<
le小于等于<=
like模糊查询
notLike模糊查询 NOT LIKE
inIN 查询
notInNOT IN 查询
isNullNULL 值查询
isNotNullIS NOT NULL
groupBy分组 GROUP BY
havingHAVING 关键词
orderBy排序 ORDER BY
orderAscASC 排序 ORDER BY
orderDescDESC 排序 ORDER BY
existsEXISTS 条件语句
notExistsNOT EXISTS 条件语句
betweenBETWEEN 条件语句
notBetweenNOT BETWEEN 条件语句
last拼接在最后,例如:last(“LIMIT 1”)
Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐