public interface Service<T,PK>
| Modifier and Type | Method and Description |
|---|---|
int[] |
batchInsertTable(String tableName,
List<String> columns,
List<Object[]> datas,
boolean ignoreConflict)
保存单表多项数据
|
long |
count(T model) |
long |
countByCondition(tk.mybatis.mapper.entity.Condition condition) |
int |
deleteByCondition(tk.mybatis.mapper.entity.Condition condition) |
int |
deleteByIds(List<PK> ids) |
int |
deleteByPrimaryKey(PK id) |
void |
executeSql(String sql) |
boolean |
existsWithPrimaryKey(PK key) |
org.springframework.jdbc.core.JdbcTemplate |
getJdbcTemplate() |
int |
insert(T model) |
int |
insertList(List<T> models)
批量插入
|
int |
insertListIgnoreConflict(List<T> models)
批量插入忽略冲突
|
int |
insertSelective(T model) |
int |
insertSelectiveListIgnoreConflict(List<String> insertProperties,
List<T> models)
按属性批量插入数据并忽略冲突
|
int |
insertTable(String tableName,
List<String> columns,
List<Object> datas,
boolean ignoreConflict)
保存单表多项数据
|
int |
insertTable(String tableName,
Map<String,Object> datas,
boolean ignoreConflict) |
List<Map<String,Object>> |
queryForList(String sql,
Object[] args) |
<T> List<T> |
queryForList(String sql,
Object[] args,
Class<T> elementType) |
Map<String,Object> |
queryForMap(String sql,
Object... args) |
<T> T |
queryForObject(String sql,
Class<T> requiredType,
Object... args) |
<T> T |
queryForSingleColumn(Class<T> returnClass,
String sql,
Object[] args)
根据sql语句查询单列单行数据,注意:多好请设置 limit 1;
|
List<T> |
select(T model) |
List<T> |
selectAll() |
List<T> |
selectByCondition(tk.mybatis.mapper.entity.Condition condition) |
List<T> |
selectByConditionForOffsetAndLimit(tk.mybatis.mapper.entity.Condition condition,
Integer offset,
Integer limit,
Boolean count) |
List<T> |
selectByConditionForStartPage(tk.mybatis.mapper.entity.Condition condition,
Integer pageNum,
Integer pageSize) |
List<T> |
selectByConditionForStartPage(tk.mybatis.mapper.entity.Condition condition,
Integer pageNum,
Integer pageSize,
Boolean count) |
List<T> |
selectByIds(List<PK> ids) |
T |
selectByPrimaryKey(PK id) |
T |
selectFirst(T model) |
T |
selectFirstByCondition(tk.mybatis.mapper.entity.Condition condition) |
List<T> |
selectForStartPage(T model,
Integer pageNum,
Integer pageSize) |
T |
selectOne(T model) |
int |
updateByCondition(T model,
tk.mybatis.mapper.entity.Condition condition) |
int |
updateByConditionSelective(T model,
tk.mybatis.mapper.entity.Condition condition) |
int |
updateByPrimaryKey(T model) |
int |
updateByPrimaryKeySelective(T model) |
int |
updateTable(String sql,
Object... args) |
tk.mybatis.mapper.entity.Condition |
wrapCondition(Class claz,
String[] properties)
参见
|
tk.mybatis.mapper.entity.Condition |
wrapCondition(Class claz,
String[] properties,
boolean withEnabledFilter)
返回查询条件
|
long count(T model)
boolean existsWithPrimaryKey(PK key)
long countByCondition(tk.mybatis.mapper.entity.Condition condition)
int insert(T model)
int insertSelective(T model)
int insertListIgnoreConflict(List<T> models)
models - 插入的实体对象int insertSelectiveListIgnoreConflict(List<String> insertProperties, List<T> models)
insertProperties - 需要插入的对象属性值models - 插入的实体对象int deleteByPrimaryKey(PK id)
int deleteByCondition(tk.mybatis.mapper.entity.Condition condition)
int updateByCondition(T model, tk.mybatis.mapper.entity.Condition condition)
int updateByConditionSelective(T model, tk.mybatis.mapper.entity.Condition condition)
int updateByPrimaryKey(T model)
int updateByPrimaryKeySelective(T model)
T selectFirstByCondition(tk.mybatis.mapper.entity.Condition condition)
List<T> selectByConditionForStartPage(tk.mybatis.mapper.entity.Condition condition, Integer pageNum, Integer pageSize)
List<T> selectByConditionForStartPage(tk.mybatis.mapper.entity.Condition condition, Integer pageNum, Integer pageSize, Boolean count)
List<T> selectByConditionForOffsetAndLimit(tk.mybatis.mapper.entity.Condition condition, Integer offset, Integer limit, Boolean count)
org.springframework.jdbc.core.JdbcTemplate getJdbcTemplate()
<T> T queryForObject(String sql, Class<T> requiredType, @Nullable Object... args) throws org.springframework.dao.DataAccessException
org.springframework.dao.DataAccessException<T> T queryForSingleColumn(Class<T> returnClass, String sql, Object[] args)
Map<String,Object> queryForMap(String sql, @Nullable Object... args) throws org.springframework.dao.DataAccessException
org.springframework.dao.DataAccessException<T> List<T> queryForList(String sql, Object[] args, Class<T> elementType) throws org.springframework.dao.DataAccessException
org.springframework.dao.DataAccessExceptionList<Map<String,Object>> queryForList(String sql, Object[] args) throws org.springframework.dao.DataAccessException
org.springframework.dao.DataAccessExceptionint[] batchInsertTable(String tableName, List<String> columns, List<Object[]> datas, boolean ignoreConflict)
tableName - 表名称columns - 列名datas - 要插入的数据,每行数据不能少于列数,空值需要传ignoreConflict - 是否忽略冲突
使用该方法请打开jdbc的批量驱动参数:rewriteBatchedStatements=true 批量操作batchInsert/update/deleteint insertTable(String tableName, List<String> columns, List<Object> datas, boolean ignoreConflict)
tableName - 表名称columns - 列名datas - 要插入的数据,每行数据不能少于列数,空值需要传ignoreConflict - 是否忽略冲突
使用该方法请打开jdbc的批量驱动参数:rewriteBatchedStatements=true 批量操作batchInsert/update/deletevoid executeSql(String sql)
tk.mybatis.mapper.entity.Condition wrapCondition(Class claz, String[] properties)
wrapCondition(claz, properties, withEnabledFilter=true)tk.mybatis.mapper.entity.Condition wrapCondition(Class claz, String[] properties, boolean withEnabledFilter)
claz - 类必填properties - 若非空,则查询当前实体的参数列表,若为空,则查询当前实体除了(createdBy、createdByName、version、modifiedBy、modifiedTime)以外的所有属性withEnabledFilter - 是否包含enabled=true的查询条件Copyright © 2021. All rights reserved.