Class SimpleArangoRepository<T,ID>

java.lang.Object
com.arangodb.springframework.repository.SimpleArangoRepository<T,ID>
All Implemented Interfaces:
ArangoRepository<T,ID>, CrudRepository<T,ID>, PagingAndSortingRepository<T,ID>, QueryByExampleExecutor<T>, Repository<T,ID>

@Repository public class SimpleArangoRepository<T,ID> extends Object implements ArangoRepository<T,ID>
The implementation of all CRUD, paging and sorting functionality in ArangoRepository from the Spring Data Commons CRUD repository and PagingAndSorting repository
  • Constructor Summary

    Constructors
    Constructor
    Description
    SimpleArangoRepository(ArangoTemplate arangoTemplate, Class<T> domainClass, boolean returnOriginalEntities)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    long
    Counts the number of documents in the collection for the type of this repository
    <S extends T>
    long
    count(Example<S> example)
    Counts the number of documents in the collection which match with the given example
    void
    delete(T entity)
    Deletes document in the database representing the given object, by getting it's id
    void
    Deletes all documents in the collection for this repository
    void
    deleteAll(Iterable<? extends T> entities)
    Deletes all the given documents from the database
    void
    deleteAllById(Iterable<? extends ID> ids)
    Deletes all instances of the type T with the given IDs.
    void
    Deletes the document with the given id or key
    <S extends T>
    boolean
    exists(Example<S> example)
    Checks if any documents match with the given example
    boolean
    Checks if a document exists or not based on the given id or key
    Gets all documents in the collection for the class type of this repository
    <S extends T>
    Iterable<S>
    findAll(Example<S> example)
    Finds all documents which match with the given example
    <S extends T>
    Page<S>
    findAll(Example<S> example, Pageable pageable)
    Finds all documents which match with the given example, with pagination
    <S extends T>
    Iterable<S>
    findAll(Example<S> example, Sort sort)
    Finds all documents which match with the given example, then apply the given sort to results
    findAll(Pageable pageable)
    Gets all documents in the collection for the class type of this repository, with pagination
    findAll(Sort sort)
    Gets all documents in the collection for the class type of this repository, with the given sort applied
    Finds all documents with the an id or key in the argument
    <S extends T, R>
    R
    findBy(Example<S> example, Function<FluentQuery.FetchableFluentQuery<S>,R> queryFunction)
     
    Finds if a document with the given id exists in the database
    <S extends T>
    Optional<S>
    findOne(Example<S> example)
    Finds one document which matches the given example object
    <S extends T>
    S
    save(S entity)
    Saves the passed entity to the database using repsert from the template
    <S extends T>
    Iterable<S>
    saveAll(Iterable<S> entities)
    Saves the given iterable of entities to the database using repsert from the template

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • SimpleArangoRepository

      public SimpleArangoRepository(ArangoTemplate arangoTemplate, Class<T> domainClass, boolean returnOriginalEntities)
      Parameters:
      arangoTemplate - The template used to execute much of the functionality of this class
      domainClass - the class type of this repository
      returnOriginalEntities - whether save and saveAll should return the original entities or new ones
  • Method Details

    • save

      public <S extends T> S save(S entity)
      Saves the passed entity to the database using repsert from the template
      Specified by:
      save in interface CrudRepository<T,ID>
      Parameters:
      entity - the entity to be saved to the database
      Returns:
      the updated entity with any id/key/rev saved
    • saveAll

      public <S extends T> Iterable<S> saveAll(Iterable<S> entities)
      Saves the given iterable of entities to the database using repsert from the template
      Specified by:
      saveAll in interface CrudRepository<T,ID>
      Parameters:
      entities - the iterable of entities to be saved to the database
      Returns:
      the iterable of updated entities with any id/key/rev saved in each entity
    • findById

      public Optional<T> findById(ID id)
      Finds if a document with the given id exists in the database
      Specified by:
      findById in interface CrudRepository<T,ID>
      Parameters:
      id - the id of the document to search for
      Returns:
      the object representing the document if found
    • existsById

      public boolean existsById(ID id)
      Checks if a document exists or not based on the given id or key
      Specified by:
      existsById in interface CrudRepository<T,ID>
      Parameters:
      id - represents either the key or id of a document to check for
      Returns:
      returns true if the document is found, false otherwise
    • findAll

      public Iterable<T> findAll()
      Gets all documents in the collection for the class type of this repository
      Specified by:
      findAll in interface CrudRepository<T,ID>
      Returns:
      an iterable with all the documents in the collection
    • findAllById

      public Iterable<T> findAllById(Iterable<ID> ids)
      Finds all documents with the an id or key in the argument
      Specified by:
      findAllById in interface CrudRepository<T,ID>
      Parameters:
      ids - an iterable with ids/keys of documents to get
      Returns:
      an iterable with documents in the collection which have a id/key in the argument
    • count

      public long count()
      Counts the number of documents in the collection for the type of this repository
      Specified by:
      count in interface CrudRepository<T,ID>
      Returns:
      long with number of documents
    • deleteById

      public void deleteById(ID id)
      Deletes the document with the given id or key
      Specified by:
      deleteById in interface CrudRepository<T,ID>
      Parameters:
      id - id or key of document to be deleted
    • delete

      public void delete(T entity)
      Deletes document in the database representing the given object, by getting it's id
      Specified by:
      delete in interface CrudRepository<T,ID>
      Parameters:
      entity - the entity to be deleted from the database
    • deleteAllById

      public void deleteAllById(Iterable<? extends ID> ids)
      Deletes all instances of the type T with the given IDs.
      Specified by:
      deleteAllById in interface CrudRepository<T,ID>
    • deleteAll

      public void deleteAll(Iterable<? extends T> entities)
      Deletes all the given documents from the database
      Specified by:
      deleteAll in interface CrudRepository<T,ID>
      Parameters:
      entities - iterable of entities to be deleted from the database
    • deleteAll

      public void deleteAll()
      Deletes all documents in the collection for this repository
      Specified by:
      deleteAll in interface CrudRepository<T,ID>
    • findAll

      public Iterable<T> findAll(Sort sort)
      Gets all documents in the collection for the class type of this repository, with the given sort applied
      Specified by:
      findAll in interface PagingAndSortingRepository<T,ID>
      Parameters:
      sort - the sort object to use for sorting
      Returns:
      an iterable with all the documents in the collection
    • findAll

      public Page<T> findAll(Pageable pageable)
      Gets all documents in the collection for the class type of this repository, with pagination
      Specified by:
      findAll in interface PagingAndSortingRepository<T,ID>
      Parameters:
      pageable - the pageable object to use for pagination of the results
      Returns:
      an iterable with all the documents in the collection
    • findOne

      public <S extends T> Optional<S> findOne(Example<S> example)
      Finds one document which matches the given example object
      Specified by:
      findOne in interface QueryByExampleExecutor<T>
      Type Parameters:
      S -
      Parameters:
      example - example object to construct query with
      Returns:
      An object representing the example if it exists, else null
    • findAll

      public <S extends T> Iterable<S> findAll(Example<S> example)
      Finds all documents which match with the given example
      Specified by:
      findAll in interface QueryByExampleExecutor<T>
      Type Parameters:
      S -
      Parameters:
      example - example object to construct query with
      Returns:
      iterable of all matching documents
    • findAll

      public <S extends T> Iterable<S> findAll(Example<S> example, Sort sort)
      Finds all documents which match with the given example, then apply the given sort to results
      Specified by:
      findAll in interface QueryByExampleExecutor<T>
      Type Parameters:
      S -
      Parameters:
      example - example object to construct query with
      sort - sort object to sort results
      Returns:
      sorted iterable of all matching documents
    • findAll

      public <S extends T> Page<S> findAll(Example<S> example, Pageable pageable)
      Finds all documents which match with the given example, with pagination
      Specified by:
      findAll in interface QueryByExampleExecutor<T>
      Type Parameters:
      S -
      Parameters:
      example - example object to construct query with
      pageable - pageable object to apply pagination with
      Returns:
      iterable of all matching documents, with pagination
    • count

      public <S extends T> long count(Example<S> example)
      Counts the number of documents in the collection which match with the given example
      Specified by:
      count in interface QueryByExampleExecutor<T>
      Type Parameters:
      S -
      Parameters:
      example - example object to construct query with
      Returns:
      number of matching documents found
    • exists

      public <S extends T> boolean exists(Example<S> example)
      Checks if any documents match with the given example
      Specified by:
      exists in interface QueryByExampleExecutor<T>
      Type Parameters:
      S -
      Parameters:
      example -
      Returns:
      true if any matches are found, else false
    • findBy

      public <S extends T, R> R findBy(Example<S> example, Function<FluentQuery.FetchableFluentQuery<S>,R> queryFunction)
      Specified by:
      findBy in interface QueryByExampleExecutor<T>