接口 IBaseService<T extends BaseEntity,ID>
-
- 所有已知实现类:
BaseServiceImpl
public interface IBaseService<T extends BaseEntity,ID>服务层接口的父接口,继承此接口默认下面的这些方法要实现的,采用泛型的写法- 作者:
- youta
-
-
方法概要
所有方法 实例方法 抽象方法 修饰符和类型 方法 说明 List<T>advancedQuery(T entity)Description: 高级模糊查询,查询条件在实体中org.springframework.data.domain.Page<T>advancedQuery(T entity, org.springframework.data.domain.Pageable pageable)Description: 高级模糊查询及分页SetadvanceSearchProperty(String property, String value)查询某个属性集合,不包含重复数据longcount()Description:<S extends T>
longcount(org.springframework.data.domain.Example<S> example)Returns the number of instances matching the givenExample.voiddelete(T var1)Description:voiddeleteAll()Description:voiddeleteAll(Iterable<? extends T> var1)Description:intdeleteAllById(Iterable<ID> var1)Description:使用主键批量删除voiddeleteAllInBatch()Description:voiddeleteById(ID var1)根据id查询voiddeleteInBatch(Iterable<T> var1)Description:<S extends T>
booleanexists(org.springframework.data.domain.Example<S> example)Checks whether the data store contains elements that match the givenExample.booleanexistsByEntityProperty(String propertyName, String propertyValue)Description: 根据实体的属性名称判断,实体是否存在, 注意:使用此方法,要自己保证属性名称的正确性,否则抛异常!booleanexistsById(ID var1)Description: 根据ID检查实体是否存在Iterable<T>findAll()Description:<S extends T>
Iterable<S>findAll(org.springframework.data.domain.Example<S> example)Returns all entities matching the givenExample.<S extends T>
org.springframework.data.domain.Page<S>findAll(org.springframework.data.domain.Example<S> example, org.springframework.data.domain.Pageable pageable)Returns aPageof entities matching the givenExample.<S extends T>
Iterable<S>findAll(org.springframework.data.domain.Example<S> example, org.springframework.data.domain.Sort sort)Returns all entities matching the givenExampleapplying the givenSort.org.springframework.data.domain.Page<T>findAll(org.springframework.data.domain.Pageable var1)Description:Iterable<T>findAll(org.springframework.data.domain.Sort var1)Description:Iterable<T>findAllById(Iterable<ID> var1)Description:Optional<T>findById(ID var1)Description:<S extends T>
Optional<S>findOne(org.springframework.data.domain.Example<S> example)Returns a single entity matching the givenExampleor null if none was found.voidflush()Description:TgetOne(ID var1)Description:voidnotifyOthers(Object arg)自己的状态改变了,通知所有依赖自己的组件进行缓存清除, 通常的增删改的方法都需要调用这个方法,来维持缓存一致性voidregistObservers(Observer... observers)注册观察者,即哪些组件观察自己,让子类调用此方法实现观察者注册<S extends T>
Ssave(S var1)Description:<S extends T>
Iterable<S>saveAll(Iterable<S> var1)Description:<S extends T>
SsaveAndFlush(S var1)Description:voidupdate(Observable o, Object arg)这是观察别人,别人更新了之后来更新自己的 其实此处不需要被观察者的任何数据,只是为了知道被观察者状态变了,自己的相关缓存也就需要清除了,否则不一致 例如:观察A对象,但是A对象被删除了,那个自己这边关联查询与A有关的缓存都应该清除 子类重写此方法在方法前面加上清除缓存的注解,或者在方法体内具体执行一些清除缓存的代码。<S extends T>
Supdate(S var1)Description:更新实体的方法,很多时候保存和更新的处理逻辑是不一样的,权限也是不一样的,所以单独分开
-
-
-
方法详细资料
-
findAll
org.springframework.data.domain.Page<T> findAll(org.springframework.data.domain.Pageable var1)
Description:- 参数:
var1- 分页对象- 返回:
- Page
-
findAll
Iterable<T> findAll(org.springframework.data.domain.Sort var1)
Description:- 参数:
var1- sort对象- 返回:
- Iterable
-
findAllById
Iterable<T> findAllById(Iterable<ID> var1)
Description:- 参数:
var1- 可迭代的id集合- 返回:
- java.lang.Iterable
-
findOne
<S extends T> Optional<S> findOne(org.springframework.data.domain.Example<S> example)
Returns a single entity matching the givenExampleor null if none was found.- 参数:
example- must not be null.- 返回:
- a single entity matching the given
ExampleorOptional.empty()if none was found. - 抛出:
org.springframework.dao.IncorrectResultSizeDataAccessException- if the Example yields more than one result.
-
findAll
<S extends T> Iterable<S> findAll(org.springframework.data.domain.Example<S> example)
Returns all entities matching the givenExample. In case no match could be found an emptyIterableis returned.- 参数:
example- must not be null.- 返回:
- all entities matching the given
Example.
-
findAll
<S extends T> Iterable<S> findAll(org.springframework.data.domain.Example<S> example, org.springframework.data.domain.Sort sort)
Returns all entities matching the givenExampleapplying the givenSort. In case no match could be found an emptyIterableis returned.- 参数:
example- must not be null.sort- theSortspecification to sort the results by, must not be null.- 返回:
- all entities matching the given
Example. - 从以下版本开始:
- 1.10
-
findAll
<S extends T> org.springframework.data.domain.Page<S> findAll(org.springframework.data.domain.Example<S> example, org.springframework.data.domain.Pageable pageable)
Returns aPageof entities matching the givenExample. In case no match could be found, an emptyPageis returned.- 参数:
example- must not be null.pageable- can be null.- 返回:
- a
Pageof entities matching the givenExample.
-
saveAll
<S extends T> Iterable<S> saveAll(Iterable<S> var1)
Description:- 参数:
var1- 可迭代的实体集合- 返回:
- java.lang.Iterable
-
flush
void flush()
Description:
-
saveAndFlush
<S extends T> S saveAndFlush(S var1)
Description:- 参数:
var1- 实体- 返回:
- S
-
save
<S extends T> S save(S var1)
Description:- 参数:
var1- 实体- 返回:
- S
-
delete
void delete(T var1)
Description:- 参数:
var1- 实体
-
deleteById
void deleteById(ID var1)
根据id查询- 参数:
var1- id
-
deleteAll
void deleteAll()
Description:
-
deleteAllInBatch
void deleteAllInBatch()
Description:
-
existsById
boolean existsById(ID var1)
Description: 根据ID检查实体是否存在- 参数:
var1- id主键- 返回:
- boolean true存在,false 不存在
-
count
long count()
Description:- 返回:
- long
-
count
<S extends T> long count(org.springframework.data.domain.Example<S> example)
Returns the number of instances matching the givenExample.- 参数:
example- theExampleto count instances for. Must not be null.- 返回:
- the number of instances matching the
Example.
-
exists
<S extends T> boolean exists(org.springframework.data.domain.Example<S> example)
Checks whether the data store contains elements that match the givenExample.- 参数:
example- theExampleto use for the existence check. Must not be null.- 返回:
- true if the data store contains elements that match the given
Example.
-
existsByEntityProperty
boolean existsByEntityProperty(String propertyName, String propertyValue) throws NoSuchFieldException
Description: 根据实体的属性名称判断,实体是否存在, 注意:使用此方法,要自己保证属性名称的正确性,否则抛异常!- 参数:
propertyName- 实体的属性名,暂时支持字符串类型propertyValue- 实体的属性名对应的值,仅支持简单的基本类型的值为字符串的,不支持其他的自定义类的类型- 返回:
- boolean true实体存在;false 不存在。
- 抛出:
NoSuchFieldException
-
deleteAllById
int deleteAllById(Iterable<ID> var1)
Description:使用主键批量删除- 参数:
var1- 可迭代的id集合- 返回:
- int
-
update
<S extends T> S update(S var1)
Description:更新实体的方法,很多时候保存和更新的处理逻辑是不一样的,权限也是不一样的,所以单独分开- 参数:
var1- 要更新的实体- 返回:
- S
-
advancedQuery
List<T> advancedQuery(T entity)
Description: 高级模糊查询,查询条件在实体中- 参数:
entity- 包含高级查询条件的实体- 返回:
- java.util.List<T>
-
advancedQuery
org.springframework.data.domain.Page<T> advancedQuery(T entity, org.springframework.data.domain.Pageable pageable)
Description: 高级模糊查询及分页- 参数:
entity- 包含高级查询条件的实体pageable- 分页参数对象- 返回:
- Page
-
advanceSearchProperty
Set advanceSearchProperty(String property, String value)
查询某个属性集合,不包含重复数据- 参数:
property- 驼峰式的属性value- 模糊查询的value值- 返回:
- Set 集合
-
registObservers
@Async void registObservers(Observer... observers)
注册观察者,即哪些组件观察自己,让子类调用此方法实现观察者注册
-
notifyOthers
@Async void notifyOthers(Object arg)
自己的状态改变了,通知所有依赖自己的组件进行缓存清除, 通常的增删改的方法都需要调用这个方法,来维持缓存一致性- 参数:
arg- 通知观察者时可以传递礼物arg,即数据,如果不需要数据就传递null;
-
update
@Async void update(Observable o, Object arg)
这是观察别人,别人更新了之后来更新自己的 其实此处不需要被观察者的任何数据,只是为了知道被观察者状态变了,自己的相关缓存也就需要清除了,否则不一致 例如:观察A对象,但是A对象被删除了,那个自己这边关联查询与A有关的缓存都应该清除 子类重写此方法在方法前面加上清除缓存的注解,或者在方法体内具体执行一些清除缓存的代码。- 参数:
o- 被观察的对象arg- 传递的数据
-
-