mybatis-plus与tk.mybatis对比参考
·
| tk.mybatis | mybatis-plus:service接口 | mybatis-plus:mapper接口 | ||
| 查询 | ||||
| T selectByPrimaryKey | T getById | T selectById | ||
| int selectCount | int count | Integer selectCount | ||
| List<T> selectByExample | List<T> list() | List<T> selectList | ||
| int selectCountByExample | Integer selectCount | |||
| T selectOneByExample | T getOne | T selectOne | ||
| List<T> selectAll | List<T> list() | List<T> selectList | ||
| boolean existsWithPrimaryKey | ||||
| T selectOne | T getOne | T selectOne | ||
| List<T> selectByIds | Collection<T> listByIds | List<T> selectBatchIds | 根据主键字符串进行查询,类中只有存在一个带有@Id注解的字段 | |
| 新增 | ||||
| int insert | int insert | |||
| int insertSelective | boolean save | int insert | 保存一个实体,null的属性不会保存,会使用数据库默认值 | |
| 修改 | ||||
| int updateByPrimaryKey | int updateById | |||
| int updateByPrimaryKeySelective | boolean updateById | int updateById | 根据主键更新属性不为null的值 | |
| int updateByExample | int update | |||
| int updateByExampleSelective | boolean update | int update | ||
| 删除 | ||||
| int deleteByPrimaryKey | boolean removeById | int deleteById | ||
| int delete | boolean remove | int delete | ||
| int deleteByIds | boolean removeByIds | int deleteBatchIds | 根据主键字符串进行删除,类中只有存在一个带有@Id注解的字段 | |
| int deleteByExample | boolean removeByMap | int deleteByMap | ||
| 批量操作 | ||||
| insertList | boolean saveBatch | |||
| updateListByPrimaryKeySelective | boolean updateBatchById | |||
| updateByPrimaryKeySelectiveForce | update(updateWrapper) | |||
| updateByExampleSelectiveForce | update(updateWrapper) | |||
| 分页 | ||||
| pageHelper | IPage<T> page | |||
| 扩展 | ||||
| alwaysUpdateSomeColumnById | 根据 ID 更新固定的那几个字段(但是不包含逻辑删除) | |||
| insertBatchSomeColumn | 批量新增数据,自选字段 insert | |||
| deleteByIdWithFill | 根据 id 逻辑删除数据,并带字段填充功能 | |||
| 排序 | ||||
| searchCriteria.setExampleOrderByClause(example, BlackList.class); | orderByAsc(boolean condition, R... columns) | |||
| 条件构造 | ||||
| Example | QueryWrapper | |||
| 查询方式 | 说明 | |||
| select | 设置查询字段 | |||
| and | AND 语句,拼接 + AND (字段=值) | |||
| or | OR 语句,拼接 + OR (字段=值) | |||
| eq | 等于= | |||
| allEq | 基于 map 内容等于= | |||
| ne | 不等于<> | |||
| gt | 大于> | |||
| ge | 大于等于>= | |||
| lt | 小于< | |||
| le | 小于等于<= | |||
| like | 模糊查询 | |||
| notLike | 模糊查询 NOT LIKE | |||
| in | IN 查询 | |||
| notIn | NOT IN 查询 | |||
| isNull | NULL 值查询 | |||
| isNotNull | IS NOT NULL | |||
| groupBy | 分组 GROUP BY | |||
| having | HAVING 关键词 | |||
| orderBy | 排序 ORDER BY | |||
| orderAsc | ASC 排序 ORDER BY | |||
| orderDesc | DESC 排序 ORDER BY | |||
| exists | EXISTS 条件语句 | |||
| notExists | NOT EXISTS 条件语句 | |||
| between | BETWEEN 条件语句 | |||
| notBetween | NOT BETWEEN 条件语句 | |||
| last | 拼接在最后,例如:last(“LIMIT 1”) |
魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。
更多推荐


所有评论(0)