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 TypeMethodDescriptionlong
count()
<S extends T>
longcount
(org.springframework.data.domain.Example<S> example) void
void
void
void
deleteAllById
(Iterable<? extends ID> ids) void
deleteById
(ID id) <S extends T>
booleanexists
(org.springframework.data.domain.Example<S> example) boolean
existsById
(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 givenExample
applying 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:MongoRepository
Inserts 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:
insert
in interfaceMongoRepository<T,
ID> - Parameters:
entity
- must not be null.- Returns:
- the saved entity
-
insert
Description copied from interface:MongoRepository
Inserts 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:
insert
in interfaceMongoRepository<T,
ID> - Parameters:
entities
- must not be null.- Returns:
- the saved entities
-
findOne
- Specified by:
findOne
in interfaceorg.springframework.data.repository.query.QueryByExampleExecutor<T>
-
findAll
Description copied from interface:MongoRepository
Returns all entities matching the givenExample
. In case no match could be found an emptyList
is returned.
By default theExample
uses 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 anUntypedExampleMatcher
withExample.of(Object, org.springframework.data.domain.ExampleMatcher)
.- Specified by:
findAll
in interfaceMongoRepository<T,
ID> - Specified by:
findAll
in 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:MongoRepository
Returns all entities matching the givenExample
applying the givenSort
. In case no match could be found an emptyList
is returned.
By default theExample
uses 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 anUntypedExampleMatcher
withExample.of(Object, org.springframework.data.domain.ExampleMatcher)
.- Specified by:
findAll
in interfaceMongoRepository<T,
ID> - Specified by:
findAll
in 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:
findAll
in interfaceorg.springframework.data.repository.query.QueryByExampleExecutor<T>
-
count
- Specified by:
count
in interfaceorg.springframework.data.repository.query.QueryByExampleExecutor<T>
-
exists
- Specified by:
exists
in 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:
findBy
in interfaceorg.springframework.data.repository.query.QueryByExampleExecutor<T>
-