public class ServiceImpl<M extends BaseMapper<T,PK>,T,PK extends Serializable> extends Object implements IService<T,PK>
IService 实现类( 泛型:M 是 mapper 对象,T 是实体 , PK 是主键泛型 )
| 限定符和类型 | 字段和说明 |
|---|---|
protected M |
baseMapper |
protected org.slf4j.Logger |
logger
子类不用再定义logger对象
|
| 构造器和说明 |
|---|
ServiceImpl() |
| 限定符和类型 | 方法和说明 |
|---|---|
boolean |
deleteBatchIds(List<? extends Serializable> idList)
删除(根据ID 批量删除)
|
boolean |
deleteById(Serializable id)
根据 ID 删除
|
boolean |
deleteByMap(Map<String,Object> columnMap)
根据 columnMap 条件,删除记录
|
boolean |
deleteSelective(T entity)
根据 entity 条件,删除记录
|
boolean |
insert(T entity)
插入一条记录
|
boolean |
insertBatch(List<T> entityList)
插入(批量),该方法不适合 Oracle
|
boolean |
insertOrUpdate(T entity)
TableId 注解存在更新记录,否插入一条记录
|
boolean |
insertOrUpdate(T entity,
boolean isSelective)
TableId 注解存在更新记录,否插入一条记录
|
boolean |
insertOrUpdateSelective(T entity)
TableId 注解存在更新记录,否插入一条记录 (选择字段, null 字段不插入)
|
boolean |
insertSelective(T entity)
插入一条记录(选择字段, null 字段不插入)
|
protected boolean |
retBool(int result)
判断数据库操作是否成功
|
List<T> |
selectBatchIds(List<? extends Serializable> idList)
查询(根据ID 批量查询)
|
T |
selectById(Serializable id)
根据 ID 查询
|
List<T> |
selectByMap(Map<String,Object> columnMap)
查询(根据 columnMap 条件)
|
int |
selectCount(EntityWrapper<T> entityWrapper)
根据 EntityWrapper 条件,查询总记录数
|
int |
selectCount(T entity)
根据 entity 条件,查询总记录数
|
List<T> |
selectList(EntityWrapper<T> entityWrapper)
查询列表
|
T |
selectOne(EntityWrapper<T> entityWrapper)
根据 EntityWrapper,查询一条记录
|
T |
selectOne(T entity)
根据 entity 条件,查询一条记录
|
Page<T> |
selectPage(Page<T> page,
EntityWrapper<T> entityWrapper)
翻页查询
|
boolean |
update(T entity,
T whereEntity)
根据 whereEntity 条件,更新记录
|
boolean |
updateBatchById(List<T> entityList)
根据ID 批量更新
|
boolean |
updateById(T entity)
根据 ID 修改
|
boolean |
updateSelective(T entity,
T whereEntity)
根据 whereEntity 条件,选择更新记录
|
boolean |
updateSelectiveById(T entity)
根据 ID 选择修改
|
protected org.slf4j.Logger logger
@Autowired protected M extends BaseMapper<T,PK> baseMapper
protected boolean retBool(int result)
result - 数据库操作返回影响条数@Transactional(rollbackFor=java.lang.Exception.class) public boolean insertOrUpdate(T entity, boolean isSelective)
TableId 注解存在更新记录,否插入一条记录
entity - 实体对象isSelective - true 选择字段 false 不选择字段public boolean insertOrUpdate(T entity)
IServiceTableId 注解存在更新记录,否插入一条记录
insertOrUpdate 在接口中 IService<T,PK extends Serializable>entity - 实体对象public boolean insertOrUpdateSelective(T entity)
IServiceTableId 注解存在更新记录,否插入一条记录 (选择字段, null 字段不插入)
insertOrUpdateSelective 在接口中 IService<T,PK extends Serializable>entity - 实体对象@Transactional(rollbackFor=java.lang.Exception.class) public boolean insert(T entity)
IService插入一条记录
insert 在接口中 IService<T,PK extends Serializable>entity - 实体对象@Transactional(rollbackFor=java.lang.Exception.class) public boolean insertSelective(T entity)
IService插入一条记录(选择字段, null 字段不插入)
insertSelective 在接口中 IService<T,PK extends Serializable>entity - 实体对象@Transactional(rollbackFor=java.lang.Exception.class) public boolean insertBatch(List<T> entityList)
IService插入(批量),该方法不适合 Oracle
insertBatch 在接口中 IService<T,PK extends Serializable>entityList - 实体对象列表@Transactional(rollbackFor=java.lang.Exception.class) public boolean deleteById(Serializable id)
IService根据 ID 删除
deleteById 在接口中 IService<T,PK extends Serializable>id - 主键ID@Transactional(rollbackFor=java.lang.Exception.class) public boolean deleteByMap(Map<String,Object> columnMap)
IService根据 columnMap 条件,删除记录
deleteByMap 在接口中 IService<T,PK extends Serializable>columnMap - 表字段 map 对象@Transactional(rollbackFor=java.lang.Exception.class) public boolean deleteSelective(T entity)
IService根据 entity 条件,删除记录
deleteSelective 在接口中 IService<T,PK extends Serializable>entity - 实体对象@Transactional(rollbackFor=java.lang.Exception.class) public boolean deleteBatchIds(List<? extends Serializable> idList)
IService删除(根据ID 批量删除)
deleteBatchIds 在接口中 IService<T,PK extends Serializable>idList - 主键ID列表@Transactional(rollbackFor=java.lang.Exception.class) public boolean updateById(T entity)
IService根据 ID 修改
updateById 在接口中 IService<T,PK extends Serializable>entity - 实体对象@Transactional(rollbackFor=java.lang.Exception.class) public boolean updateSelectiveById(T entity)
IService根据 ID 选择修改
updateSelectiveById 在接口中 IService<T,PK extends Serializable>entity - 实体对象@Transactional(rollbackFor=java.lang.Exception.class) public boolean update(T entity, T whereEntity)
IService根据 whereEntity 条件,更新记录
update 在接口中 IService<T,PK extends Serializable>entity - 实体对象whereEntity - 实体查询条件(可以为 null)@Transactional(rollbackFor=java.lang.Exception.class) public boolean updateSelective(T entity, T whereEntity)
IService根据 whereEntity 条件,选择更新记录
updateSelective 在接口中 IService<T,PK extends Serializable>entity - 实体对象whereEntity - 实体查询条件(可以为 null)@Transactional(rollbackFor=java.lang.Exception.class) public boolean updateBatchById(List<T> entityList)
IService根据ID 批量更新
updateBatchById 在接口中 IService<T,PK extends Serializable>entityList - 实体对象列表public T selectById(Serializable id)
IService根据 ID 查询
selectById 在接口中 IService<T,PK extends Serializable>id - 主键IDpublic List<T> selectBatchIds(List<? extends Serializable> idList)
IService查询(根据ID 批量查询)
selectBatchIds 在接口中 IService<T,PK extends Serializable>idList - 主键ID列表public List<T> selectByMap(Map<String,Object> columnMap)
IService查询(根据 columnMap 条件)
selectByMap 在接口中 IService<T,PK extends Serializable>columnMap - 表字段 map 对象public T selectOne(T entity)
IService根据 entity 条件,查询一条记录
selectOne 在接口中 IService<T,PK extends Serializable>entity - 实体对象public T selectOne(EntityWrapper<T> entityWrapper)
IService根据 EntityWrapper,查询一条记录
selectOne 在接口中 IService<T,PK extends Serializable>entityWrapper - 实体对象public int selectCount(T entity)
IService根据 entity 条件,查询总记录数
selectCount 在接口中 IService<T,PK extends Serializable>entity - 实体对象public int selectCount(EntityWrapper<T> entityWrapper)
IService根据 EntityWrapper 条件,查询总记录数
selectCount 在接口中 IService<T,PK extends Serializable>entityWrapper - 实体对象public List<T> selectList(EntityWrapper<T> entityWrapper)
IService查询列表
selectList 在接口中 IService<T,PK extends Serializable>entityWrapper - 实体包装类 EntityWrapperpublic Page<T> selectPage(Page<T> page, EntityWrapper<T> entityWrapper)
IService翻页查询
selectPage 在接口中 IService<T,PK extends Serializable>page - 翻页对象entityWrapper - 实体包装类 EntityWrapperCopyright © 2016. All rights reserved.