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
-
Constructor Summary
ConstructorDescriptionSimpleMongoRepository
(MongoEntityInformation<T, ID> metadata, MongoOperations mongoOperations) -
Method Summary
Modifier and TypeMethodDescriptionlong
count()
<S extends T>
longvoid
void
void
void
deleteAllById
(Iterable<? extends ID> ids) void
deleteById
(ID id) <S extends T>
booleanboolean
existsById
(ID id) findAll()
Returns all entities matching the givenExample
.findAllById
(Iterable<ID> ids) <S extends T,
R>
RfindBy
(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:
save
in interfaceCrudRepository<T,
ID>
-
saveAll
- Specified by:
saveAll
in interfaceCrudRepository<T,
ID> - Specified by:
saveAll
in interfaceListCrudRepository<T,
ID>
-
findById
- Specified by:
findById
in interfaceCrudRepository<T,
ID>
-
existsById
- Specified by:
existsById
in interfaceCrudRepository<T,
ID>
-
findAll
- Specified by:
findAll
in interfaceCrudRepository<T,
ID> - Specified by:
findAll
in interfaceListCrudRepository<T,
ID>
-
findAllById
- Specified by:
findAllById
in interfaceCrudRepository<T,
ID> - Specified by:
findAllById
in interfaceListCrudRepository<T,
ID>
-
count
public long count()- Specified by:
count
in interfaceCrudRepository<T,
ID>
-
deleteById
- Specified by:
deleteById
in interfaceCrudRepository<T,
ID>
-
delete
- Specified by:
delete
in interfaceCrudRepository<T,
ID>
-
deleteAllById
- Specified by:
deleteAllById
in interfaceCrudRepository<T,
ID>
-
deleteAll
- Specified by:
deleteAll
in interfaceCrudRepository<T,
ID>
-
deleteAll
public void deleteAll()- Specified by:
deleteAll
in interfaceCrudRepository<T,
ID>
-
findAll
- Specified by:
findAll
in interfacePagingAndSortingRepository<T,
ID>
-
findAll
- Specified by:
findAll
in interfaceListPagingAndSortingRepository<T,
ID> - Specified by:
findAll
in interfacePagingAndSortingRepository<T,
ID>
-
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 interfaceQueryByExampleExecutor<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 interfaceQueryByExampleExecutor<T>
- See Also:
-
findAll
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 interfaceQueryByExampleExecutor<T>
- See Also:
-
findAll
- Specified by:
findAll
in interfaceQueryByExampleExecutor<T>
-
count
- Specified by:
count
in interfaceQueryByExampleExecutor<T>
-
exists
- Specified by:
exists
in interfaceQueryByExampleExecutor<T>
-
findBy
public <S extends T,R> R findBy(Example<S> example, Function<FluentQuery.FetchableFluentQuery<S>, R> queryFunction) - Specified by:
findBy
in interfaceQueryByExampleExecutor<T>
-