queryWrapper);
条件查询wrapper
List listObjs(Wrapper queryWrapper, Function<? super Object, V> mapper);
分页
无条件分页查询:IPage page(IPage page);
无条件分页查询:IPage<Map<String, Object>> pageMaps(IPage page);
条件分页查询:IPage page(IPage page, Wrapper queryWrapper);
条件分页查询:IPage<Map<String, Object>> pageMaps(IPage page, Wrapper queryWrapper);
统计
查询总记录数:int count();
条件查询总记录数wrapper
int count(Wrapper queryWrapper);
链式-查询
QueryChainWrapper query();
query().eq("column", value).one();
lambda链式查询(不支持 Kotlin)
LambdaQueryChainWrapper lambdaQuery();
lambdaQuery().eq(Entity::getId, value).list();
插入
选择字段,策略插入一条记录:boolean save(T entity);
批量插入:boolean saveBatch(Collection entityList);
批量插入:boolean saveBatch(Collection entityList, int batchSize);
public void insertUser(){
User user = new User();
user.setName("xiaoming");
user.setPassword(123456);
int result = userService.save(user);
System.out.println(result); // 受影响的行数
System.out.println(user); // 结果会自动回填
}
插入 / 更新
TableId 注解存在更新记录,否插入一条记录
boolean saveOrUpdate(T entity);
根据updateWrapper尝试更新,否继续执行saveOrUpdate(T)方法
boolean saveOrUpdate(T entity, Wrapper updateWrapper);
批量修改插入
boolean saveOrUpdateBatch(Collection entityList);
批量修改插入
boolean saveOrUpdateBatch(Collection entityList, int batchSize);
更新
根据Id更新:boolean updateById(T entity);
批量更新:boolean updateBatchById(Collection entityList);
批量更新:boolean updateBatchById(Collection entityList, int batchSize);
条件更新wrapper(需要设置sqlset)
boolean update(Wrapper updateWrapper);
条件更新wrapper
boolean update(T entity, Wrapper updateWrapper);
删除
根据Id删除:boolean removeById(Serializable id);
批量删除:boolean removeByIds(Collection<? extends Serializable> idList);
条件删除wrapper:boolean remove(Wrapper queryWrapper);
条件删除map:boolean removeByMap(Map<String, Object> columnMap);