个人笔记-通用mapper

个人笔记-通用mapper

Select

T selectOne(T record)

根据实体中的属性进行查询,只能有一个返回值,有多个结果则抛出异常,查询条件使用等号

List select(T record)

根据实体中的属性值进行查询,查询条件使用等号

List selectAll()

查询全部结果

int selectCount(T record)

根据实体中的属性查询总数,查询条件使用等号

T selectByPrimaryKey(Object key)

根据主键字段进行查询,方法参数必须包含完整的主键属性,查询条件使用等号

boolean existsWithPrimaryKey(Object key)

根据主键字段查询总数,方法参数必须包含完整的主键属性,查询条件使用等号

List selectByExample(Object example)

根据example条件进行查询一条或多条数据

selectOneByExample(Object example)

根据example条件查询一条数据

selectCountByExample(Object example)

根据example条件查询记录数

Insert

int insert(T record)

保存一个实体,实体中缺省的属性也会保存,使用null保存而不是数据库默认值

int insertSelective(T record)

保存一个实体,null的属性不会保存,会使用数据库默认值,无默认值则使用null

Update

int updateByPrimaryKey(T record)

根据主键更新实体全部字段,实体中缺省的字段也会被更新,被更新为null

int updateByPrimaryKeySelective(T record)

根据主键更新属性不为null的值,实体中缺省的字段不会被更新

int updateByExample(@Param(“record”) T record, @Param(“example”) Object example)

根据example条件更新实体record包含的全部属性,实体中缺省的值也会被更新,更新为null

int updateByExampleSelective(@Param(“record”) T record, @Param(“example”) Object example)

根据example条件更新实体record包含的不是null的属性值,实体中缺省的字段不会被更新

Delete

int delete(T record)

根据实体属性作为条件进行删除,查询条件使用等号

int deleteByPrimaryKey(object key)

根据主键字段进行删除,方法参数必须包含完整的主键属性

int deleteByExample(Object example)

根据example条件删除数据

Example

methoddesc
example.setOrderByClause(“字段名 DESC\ASC”)添加升序排列条件,DESC为降序
example.setDistinct(false)是否去重
criteria.andIsNull()字段为null
criteria.andNotNull()字段不为null
criteria.andEqualTo()字段等于
criteria.andNotEqualTo()字段不等于
criteria.andGreaterThan()字段大于
criteria.andGreaterThanOrEqualTo()字段大于等于
criteria.andLessThan()字段小于
criteria.andLessThanOrEqualTo()字段小于等于
criteria.andIn()字段在List<?>中
criteria.andNotIn()字段不在List<?>中
criteria.andLike("%" + value + “%”)字段为value的模糊查询条件
criteria.andNotLike("%" + value + “%”)字段不为value的模糊查询条件
criteria.andBetween(value1, value2)字段在value1和value2之间
criteria.andNotBetween(value1, value2)字段不在value1和value2之间
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值