MyBatis statement record

Simplified version, if you are in a hurry, just read this, but the official website is the same

CRUD interface | MyBatis-Plus (baomidou.com)

1. Save
// ​​Insert a record (select field, strategy insertion)
boolean save(T entity);
// Insert (batch)
boolean saveBatch(Collection<T> entityList);
// Insert (batch)
boolean saveBatch(Collection<T > entityList, int batchSize);
2. Remove
// ​​Delete records according to the conditions set by queryWrapper
boolean remove(Wrapper<T> queryWrapper);
// Delete records according to ID
boolean removeById(Serializable id);
// Delete records according to columnMap conditions
boolean removeByMap(Map<String, Object> columnMap);
// Delete (batch deletion based on ID)
boolean removeByIds(Collection<? extends Serializable> idList);
3. Update
// According to UpdateWrapper conditions, updating records requires setting sqlset
boolean update( Wrapper<T> updateWrapper);
// Update records based on whereWrapper conditions
boolean update(T updateEntity, Wrapper<T> whereWrapper);
// Select and modify based on ID
boolean updateById(T entity);
// Update in batches based on ID
boolean updateBatchById(Collection<T> entityList);
// Update in batches based on ID
boolean updateBatchById (Collection<T> entityList, int batchSize);
4. Get
// Query
T based on ID getById(Serializable id);
// Query a record based on Wrapper. If there are multiple result sets, an exception will be thrown. Randomly pick one and add restrictions wrapper.last("LIMIT 1")
T getOne(Wrapper<T> queryWrapper);
// According to Wrapper, query a record
T getOne(Wrapper <T> queryWrapper, boolean throwEx);
// Query a record based on Wrapper
Map<String, Object> getMap(Wrapper<T> queryWrapper);
// Query a record based on Wrapper
<V> V getObj(Wrapper<T> queryWrapper, Function<? super Object, V> mapper);
5. List
// Query all
List<T> list();
// Query
list List<T> list(Wrapper< T> queryWrapper);
// Query (batch query based on ID)
Collection<T> listByIds(Collection<? extends Serializable> idList);
// Query (based on columnMap conditions)
Collection<T> listByMap(Map<String, Object> columnMap );
// Query all lists
List<Map<String, Object>> listMaps();
// Query list
List<Map<String, Object>> listMaps(Wrapper<T> queryWrapper);
// Query all records
List<Object > listObjs();
// Query all records
<V> List<V> listObjs(Function<? super Object,V> mapper);
// Query all records based on Wrapper conditions
List<Object> listObjs(Wrapper<T> queryWrapper);
// Query all records
<V> according to Wrapper conditions List<V> listObjs(Wrapper<T> queryWrapper, Function<? super Object, V> mapper);
6. Page
// Unconditional paging query
IPage<T> page(IPage<T> page);
// Conditional paging query
IPage<T> page(IPage<T> page, Wrapper<T> queryWrapper);
// Unconditional paging query
IPage< Map<String, Object>> pageMaps(IPage<T> page);
// Conditional paging query
IPage<Map<String, Object>> pageMaps(IPage<T> page,Wrapper<T> queryWrapper);
7. Count
// Query the total number of records
int count();
// According to the Wrapper conditions, query the total number of records
int count(Wrapper<T> queryWrapper);
8. query
// Normal chain query
QueryChainWrapper<T> query();
//Chained query lambda style. Note: Kotlin
LambdaQueryChainWrapper<T> lambdaQuery(); is not supported

// Example:
query().eq("column", value).one();
lambdaQuery().eq(Entity::getId, value).list();
9. update
// Chained changes to ordinary
UpdateChainWrapper< T> update();
// Chained change lambda expression. Note: Kotlin
LambdaUpdateChainWrapper<T> lambdaUpdate(); is not supported.

// Example:
update().eq("column", value).remove();
lambdaUpdate().eq(Entity::getId, value).update(entity);
10. Insert
// Insert a record
int insert (T entity);
11. Delete
// Delete records according to entity conditions
int delete(@Param(Constants.WRAPPER) Wrapper<T> wrapper);
// Delete (batch delete based on ID)
int deleteBatchIds(@Param(Constants. COLLECTION) Collection<? extends Serializable> idList);
// Delete according to ID
int deleteById(Serializable id);
// Delete records according to columnMap conditions
int deleteByMap(@Param(Constants.COLUMN_MAP) Map<String, Object> columnMap);
11. Select
// Query
T based on ID selectById(Serializable id);
// Query a record based on entity conditions
T selectOne(@Param(Constants.WRAPPER) Wrapper<T> queryWrapper);

// Query (batch query based on ID)
List<T> selectBatchIds(@Param(Constants.COLLECTION) Collection<? extends Serializable> idList);
// Query all records according to entity conditions
List<T> selectList(@Param(Constants .WRAPPER) Wrapper<T> queryWrapper);
// Query (according to columnMap conditions)
List<T> selectByMap(@Param(Constants.COLUMN_MAP) Map<String, Object> columnMap);
// According to Wrapper conditions, query all records
List <Map<String, Object>> selectMaps(@Param(Constants.WRAPPER) Wrapper<T> queryWrapper);
// Query all records based on Wrapper conditions. Note: Only the value of the first field is returned
List<Object> selectObjs(@Param(Constants.WRAPPER) Wrapper<T> queryWrapper);

// According to entity conditions, query all records (and turn pages)
IPage<T> selectPage(IPage<T> page, @Param(Constants.WRAPPER) Wrapper<T> queryWrapper);
// According to Wrapper conditions, query all records ( and turn pages)
IPage<Map<String, Object>> selectMapsPage(IPage<T> page, @Param(Constants.WRAPPER) Wrapper<T> queryWrapper);
// According to Wrapper conditions, query the total number of recordsInteger
selectCount(@Param (Constants.WRAPPER) Wrapper<T> queryWrapper);

Guess you like

Origin blog.csdn.net/qq_63499305/article/details/131294020