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>

public class SimpleMongoRepository<T,ID> extends Object implements MongoRepository<T,ID>
Repository base implementation for Mongo.
Author:
Oliver Gierke, Christoph Strobl, Thomas Darimont, Mark Paluch, Mehran Behnam, Jens Schauder
  • Constructor Details

  • Method Details

    • save

      public <S extends T> S save(S entity)
      Specified by:
      save in interface org.springframework.data.repository.CrudRepository<T,ID>
    • saveAll

      public <S extends T> List<S> saveAll(Iterable<S> entities)
      Specified by:
      saveAll in interface org.springframework.data.repository.CrudRepository<T,ID>
      Specified by:
      saveAll in interface org.springframework.data.repository.ListCrudRepository<T,ID>
    • findById

      public Optional<T> findById(ID id)
      Specified by:
      findById in interface org.springframework.data.repository.CrudRepository<T,ID>
    • existsById

      public boolean existsById(ID id)
      Specified by:
      existsById in interface org.springframework.data.repository.CrudRepository<T,ID>
    • findAll

      public List<T> findAll()
      Specified by:
      findAll in interface org.springframework.data.repository.CrudRepository<T,ID>
      Specified by:
      findAll in interface org.springframework.data.repository.ListCrudRepository<T,ID>
    • findAllById

      public List<T> findAllById(Iterable<ID> ids)
      Specified by:
      findAllById in interface org.springframework.data.repository.CrudRepository<T,ID>
      Specified by:
      findAllById in interface org.springframework.data.repository.ListCrudRepository<T,ID>
    • count

      public long count()
      Specified by:
      count in interface org.springframework.data.repository.CrudRepository<T,ID>
    • deleteById

      public void deleteById(ID id)
      Specified by:
      deleteById in interface org.springframework.data.repository.CrudRepository<T,ID>
    • delete

      public void delete(T entity)
      Specified by:
      delete in interface org.springframework.data.repository.CrudRepository<T,ID>
    • deleteAllById

      public void deleteAllById(Iterable<? extends ID> ids)
      Specified by:
      deleteAllById in interface org.springframework.data.repository.CrudRepository<T,ID>
    • deleteAll

      public void deleteAll(Iterable<? extends T> entities)
      Specified by:
      deleteAll in interface org.springframework.data.repository.CrudRepository<T,ID>
    • deleteAll

      public void deleteAll()
      Specified by:
      deleteAll in interface org.springframework.data.repository.CrudRepository<T,ID>
    • findAll

      public org.springframework.data.domain.Page<T> findAll(org.springframework.data.domain.Pageable pageable)
      Specified by:
      findAll in interface org.springframework.data.repository.PagingAndSortingRepository<T,ID>
    • findAll

      public List<T> findAll(org.springframework.data.domain.Sort sort)
      Specified by:
      findAll in interface org.springframework.data.repository.ListPagingAndSortingRepository<T,ID>
      Specified by:
      findAll in interface org.springframework.data.repository.PagingAndSortingRepository<T,ID>
    • insert

      public <S extends T> S insert(S entity)
      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 using CrudRepository.save(Object) instead to avoid the usage of store-specific API.
      Specified by:
      insert in interface MongoRepository<T,ID>
      Parameters:
      entity - must not be null.
      Returns:
      the saved entity
    • insert

      public <S extends T> List<S> insert(Iterable<S> entities)
      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 to ListCrudRepository.saveAll(Iterable). Prefer using ListCrudRepository.saveAll(Iterable) to avoid the usage of store specific API.
      Specified by:
      insert in interface MongoRepository<T,ID>
      Parameters:
      entities - must not be null.
      Returns:
      the saved entities
    • findOne

      public <S extends T> Optional<S> findOne(org.springframework.data.domain.Example<S> example)
      Specified by:
      findOne in interface org.springframework.data.repository.query.QueryByExampleExecutor<T>
    • findAll

      public <S extends T> List<S> findAll(org.springframework.data.domain.Example<S> example)
      Description copied from interface: MongoRepository
      Returns all entities matching the given Example. In case no match could be found an empty List is returned.
      By default the Example 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 an UntypedExampleMatcher with Example.of(Object, org.springframework.data.domain.ExampleMatcher).
      Specified by:
      findAll in interface MongoRepository<T,ID>
      Specified by:
      findAll in interface org.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 given Example applying the given Sort. In case no match could be found an empty List is returned.
      By default the Example 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 an UntypedExampleMatcher with Example.of(Object, org.springframework.data.domain.ExampleMatcher).
      Specified by:
      findAll in interface MongoRepository<T,ID>
      Specified by:
      findAll in interface org.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 interface org.springframework.data.repository.query.QueryByExampleExecutor<T>
    • count

      public <S extends T> long count(org.springframework.data.domain.Example<S> example)
      Specified by:
      count in interface org.springframework.data.repository.query.QueryByExampleExecutor<T>
    • exists

      public <S extends T> boolean exists(org.springframework.data.domain.Example<S> example)
      Specified by:
      exists in interface org.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 interface org.springframework.data.repository.query.QueryByExampleExecutor<T>