Class SimpleMongoRepository<T,ID>
java.lang.Object
org.springframework.data.mongodb.repository.support.SimpleMongoRepository<T,ID>
- All Implemented Interfaces:
MongoRepository<T,ID>, CrudRepository<T, ID>, ListCrudRepository<T, ID>, ListPagingAndSortingRepository<T, ID>, PagingAndSortingRepository<T, ID>, QueryByExampleExecutor<T>, Repository<T, ID>
Repository base implementation for Mongo.
- Author:
- Oliver Gierke, Christoph Strobl, Thomas Darimont, Mark Paluch, Mehran Behnam, Jens Schauder, Kirill Egorov
-
Constructor Summary
ConstructorsConstructorDescriptionSimpleMongoRepository(MongoEntityInformation<T, ID> metadata, MongoOperations mongoOperations) -
Method Summary
Modifier and TypeMethodDescriptionlongcount()<S extends T>
longvoidvoidvoidvoiddeleteAllById(Iterable<? extends ID> ids) voiddeleteById(ID id) <S extends T>
booleanbooleanexistsById(ID id) findAll()Returns all entities matching the givenExample.findAllById(Iterable<ID> ids) findBy(Example<S> example, Function<FluentQuery.FetchableFluentQuery<S>, R> queryFunction) 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
- Specified by:
savein interfaceCrudRepository<T,ID>
-
saveAll
-
findById
-
existsById
- Specified by:
existsByIdin interfaceCrudRepository<T,ID>
-
findAll
- Specified by:
findAllin interfaceCrudRepository<T,ID> - Specified by:
findAllin interfaceListCrudRepository<T,ID>
-
findAllById
- Specified by:
findAllByIdin interfaceCrudRepository<T,ID> - Specified by:
findAllByIdin interfaceListCrudRepository<T,ID>
-
count
public long count()- Specified by:
countin interfaceCrudRepository<T,ID>
-
deleteById
- Specified by:
deleteByIdin interfaceCrudRepository<T,ID>
-
delete
- Specified by:
deletein interfaceCrudRepository<T,ID>
-
deleteAllById
- Specified by:
deleteAllByIdin interfaceCrudRepository<T,ID>
-
deleteAll
-
deleteAll
public void deleteAll()- Specified by:
deleteAllin interfaceCrudRepository<T,ID>
-
findAll
-
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
-
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 interfaceQueryByExampleExecutor<T>- See Also:
-
findAll
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 interfaceQueryByExampleExecutor<T>- See Also:
-
findAll
-
count
- Specified by:
countin interfaceQueryByExampleExecutor<T>
-
exists
- Specified by:
existsin interfaceQueryByExampleExecutor<T>
-
findBy
public <S extends T, R extends @Nullable Object> R findBy(Example<S> example, Function<FluentQuery.FetchableFluentQuery<S>, R> queryFunction) - Specified by:
findByin interfaceQueryByExampleExecutor<T>
-