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
ConstructorsConstructorDescriptionSimpleArangoRepository
(ArangoTemplate arangoTemplate, Class<T> domainClass, boolean returnOriginalEntities) -
Method Summary
Modifier and TypeMethodDescriptionlong
count()
Counts the number of documents in the collection for the type of this repository<S extends T>
longCounts the number of documents in the collection which match with the given examplevoid
Deletes document in the database representing the given object, by getting it's idvoid
Deletes all documents in the collection for this repositoryvoid
Deletes all the given documents from the databasevoid
deleteAllById
(Iterable<? extends ID> ids) Deletes all instances of the typeT
with the given IDs.void
deleteById
(ID id) Deletes the document with the given id or key<S extends T>
booleanChecks if any documents match with the given exampleboolean
existsById
(ID id) Checks if a document exists or not based on the given id or keyfindAll()
Gets all documents in the collection for the class type of this repositoryFinds all documents which match with the given exampleFinds all documents which match with the given example, with paginationFinds all documents which match with the given example, then apply the given sort to resultsGets all documents in the collection for the class type of this repository, with paginationGets all documents in the collection for the class type of this repository, with the given sort appliedfindAllById
(Iterable<ID> ids) Finds all documents with the an id or key in the argument<S extends T,
R>
RfindBy
(Example<S> example, Function<FluentQuery.FetchableFluentQuery<S>, R> queryFunction) Finds if a document with the given id exists in the databaseFinds one document which matches the given example object<S extends T>
Ssave
(S entity) Saves the passed entity to the database using repsert from the templateSaves the given iterable of entities to the database using repsert from the template
-
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 classdomainClass
- the class type of this repositoryreturnOriginalEntities
- whether save and saveAll should return the original entities or new ones
-
-
Method Details
-
save
Saves the passed entity to the database using repsert from the template- Specified by:
save
in interfaceCrudRepository<T,
ID> - Parameters:
entity
- the entity to be saved to the database- Returns:
- the updated entity with any id/key/rev saved
-
saveAll
Saves the given iterable of entities to the database using repsert from the template- Specified by:
saveAll
in interfaceCrudRepository<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
Finds if a document with the given id exists in the database- Specified by:
findById
in interfaceCrudRepository<T,
ID> - Parameters:
id
- the id of the document to search for- Returns:
- the object representing the document if found
-
existsById
Checks if a document exists or not based on the given id or key- Specified by:
existsById
in interfaceCrudRepository<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
Gets all documents in the collection for the class type of this repository- Specified by:
findAll
in interfaceCrudRepository<T,
ID> - Returns:
- an iterable with all the documents in the collection
-
findAllById
Finds all documents with the an id or key in the argument- Specified by:
findAllById
in interfaceCrudRepository<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 interfaceCrudRepository<T,
ID> - Returns:
- long with number of documents
-
deleteById
Deletes the document with the given id or key- Specified by:
deleteById
in interfaceCrudRepository<T,
ID> - Parameters:
id
- id or key of document to be deleted
-
delete
Deletes document in the database representing the given object, by getting it's id- Specified by:
delete
in interfaceCrudRepository<T,
ID> - Parameters:
entity
- the entity to be deleted from the database
-
deleteAllById
Deletes all instances of the typeT
with the given IDs.- Specified by:
deleteAllById
in interfaceCrudRepository<T,
ID>
-
deleteAll
Deletes all the given documents from the database- Specified by:
deleteAll
in interfaceCrudRepository<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 interfaceCrudRepository<T,
ID>
-
findAll
Gets all documents in the collection for the class type of this repository, with the given sort applied- Specified by:
findAll
in interfacePagingAndSortingRepository<T,
ID> - Parameters:
sort
- the sort object to use for sorting- Returns:
- an iterable with all the documents in the collection
-
findAll
Gets all documents in the collection for the class type of this repository, with pagination- Specified by:
findAll
in interfacePagingAndSortingRepository<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
Finds one document which matches the given example object- Specified by:
findOne
in interfaceQueryByExampleExecutor<T>
- Type Parameters:
S
-- Parameters:
example
- example object to construct query with- Returns:
- An object representing the example if it exists, else null
-
findAll
Finds all documents which match with the given example- Specified by:
findAll
in interfaceQueryByExampleExecutor<T>
- Type Parameters:
S
-- Parameters:
example
- example object to construct query with- Returns:
- iterable of all matching documents
-
findAll
Finds all documents which match with the given example, then apply the given sort to results- Specified by:
findAll
in interfaceQueryByExampleExecutor<T>
- Type Parameters:
S
-- Parameters:
example
- example object to construct query withsort
- sort object to sort results- Returns:
- sorted iterable of all matching documents
-
findAll
Finds all documents which match with the given example, with pagination- Specified by:
findAll
in interfaceQueryByExampleExecutor<T>
- Type Parameters:
S
-- Parameters:
example
- example object to construct query withpageable
- pageable object to apply pagination with- Returns:
- iterable of all matching documents, with pagination
-
count
Counts the number of documents in the collection which match with the given example- Specified by:
count
in interfaceQueryByExampleExecutor<T>
- Type Parameters:
S
-- Parameters:
example
- example object to construct query with- Returns:
- number of matching documents found
-
exists
Checks if any documents match with the given example- Specified by:
exists
in interfaceQueryByExampleExecutor<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 interfaceQueryByExampleExecutor<T>
-