Class SimpleMongoRepository<T,ID>
java.lang.Object
org.springframework.data.mongodb.repository.support.SimpleMongoRepository<T,ID>
- All Implemented Interfaces:
MongoRepository<T,,ID> org.springframework.data.repository.CrudRepository<T,,ID> org.springframework.data.repository.ListCrudRepository<T,,ID> org.springframework.data.repository.ListPagingAndSortingRepository<T,,ID> org.springframework.data.repository.PagingAndSortingRepository<T,,ID> org.springframework.data.repository.query.QueryByExampleExecutor<T>,org.springframework.data.repository.Repository<T,ID>
Repository base implementation for Mongo.
- Author:
- Oliver Gierke, Christoph Strobl, Thomas Darimont, Mark Paluch, Mehran Behnam, Jens Schauder
-
Constructor Summary
ConstructorsConstructorDescriptionSimpleMongoRepository(MongoEntityInformation<T, ID> metadata, MongoOperations mongoOperations) -
Method Summary
Modifier and TypeMethodDescriptionlongcount()<S extends T>
longcount(org.springframework.data.domain.Example<S> example) voidvoidvoidvoiddeleteAllById(Iterable<? extends ID> ids) voiddeleteById(ID id) <S extends T>
booleanexists(org.springframework.data.domain.Example<S> example) booleanexistsById(ID id) findAll()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) 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 pageable) findAll(org.springframework.data.domain.Sort sort) findAllById(Iterable<ID> ids) <S extends T,R>
RfindBy(org.springframework.data.domain.Example<S> example, Function<org.springframework.data.repository.query.FluentQuery.FetchableFluentQuery<S>, R> queryFunction) findOne(org.springframework.data.domain.Example<S> example) Inserts the given entities.<S extends T>
Sinsert(S entity) Inserts the given entity.<S extends T>
Ssave(S entity)
-
Constructor Details
-
SimpleMongoRepository
public SimpleMongoRepository(MongoEntityInformation<T, ID> metadata, MongoOperations mongoOperations) - Parameters:
metadata- must not be null.mongoOperations- must not be null.
-
-
Method Details
-
save
-
saveAll
-
findById
-
existsById
-
findAll
-
findAllById
-
count
public long count() -
deleteById
-
delete
-
deleteAllById
-
deleteAll
-
deleteAll
public void deleteAll() -
findAll
public org.springframework.data.domain.Page<T> findAll(org.springframework.data.domain.Pageable pageable) -
findAll
-
insert
Description copied from interface:MongoRepositoryInserts the given entity. Assumes the instance to be new to be able to apply insertion optimizations. Use the returned instance for further operations as the save operation might have changed the entity instance completely. Prefer usingCrudRepository.save(Object)instead to avoid the usage of store-specific API.- Specified by:
insertin interfaceMongoRepository<T,ID> - Parameters:
entity- must not be null.- Returns:
- the saved entity
-
insert
Description copied from interface:MongoRepositoryInserts the given entities. Assumes the given entities to have not been persisted yet and thus will optimize the insert over a call toListCrudRepository.saveAll(Iterable). Prefer usingListCrudRepository.saveAll(Iterable)to avoid the usage of store specific API.- Specified by:
insertin interfaceMongoRepository<T,ID> - Parameters:
entities- must not be null.- Returns:
- the saved entities
-
findOne
- Specified by:
findOnein interfaceorg.springframework.data.repository.query.QueryByExampleExecutor<T>
-
findAll
Description copied from interface:MongoRepositoryReturns all entities matching the givenExample. In case no match could be found an emptyListis returned.
By default theExampleuses typed matching restricting it to probe assignable types. For example, when sticking with the default type key (_class), the query has restrictions such as_class : { $in : [com.acme.Person] }.
To avoid the above mentioned type restriction use anUntypedExampleMatcherwithExample.of(Object, org.springframework.data.domain.ExampleMatcher).- Specified by:
findAllin interfaceMongoRepository<T,ID> - Specified by:
findAllin interfaceorg.springframework.data.repository.query.QueryByExampleExecutor<T>- See Also:
-
QueryByExampleExecutor.findAll(org.springframework.data.domain.Example)
-
findAll
public <S extends T> List<S> findAll(org.springframework.data.domain.Example<S> example, org.springframework.data.domain.Sort sort) Description copied from interface:MongoRepositoryReturns all entities matching the givenExampleapplying the givenSort. In case no match could be found an emptyListis returned.
By default theExampleuses typed matching restricting it to probe assignable types. For example, when sticking with the default type key (_class), the query has restrictions such as_class : { $in : [com.acme.Person] }.
To avoid the above mentioned type restriction use anUntypedExampleMatcherwithExample.of(Object, org.springframework.data.domain.ExampleMatcher).- Specified by:
findAllin interfaceMongoRepository<T,ID> - Specified by:
findAllin interfaceorg.springframework.data.repository.query.QueryByExampleExecutor<T>- See Also:
-
QueryByExampleExecutor.findAll(org.springframework.data.domain.Example, org.springframework.data.domain.Sort)
-
findAll
public <S extends T> org.springframework.data.domain.Page<S> findAll(org.springframework.data.domain.Example<S> example, org.springframework.data.domain.Pageable pageable) - Specified by:
findAllin interfaceorg.springframework.data.repository.query.QueryByExampleExecutor<T>
-
count
- Specified by:
countin interfaceorg.springframework.data.repository.query.QueryByExampleExecutor<T>
-
exists
- Specified by:
existsin interfaceorg.springframework.data.repository.query.QueryByExampleExecutor<T>
-
findBy
public <S extends T,R> R findBy(org.springframework.data.domain.Example<S> example, Function<org.springframework.data.repository.query.FluentQuery.FetchableFluentQuery<S>, R> queryFunction) - Specified by:
findByin interfaceorg.springframework.data.repository.query.QueryByExampleExecutor<T>
-