Class TemporalRepositoryImpl<T,ID>
java.lang.Object
org.springframework.data.jpa.repository.support.SimpleJpaRepository<T,ID>
dev.claudio.jpatemporal.repository.impl.TemporalRepositoryImpl<T,ID>
- All Implemented Interfaces:
TemporalRepository<T,ID>,org.springframework.data.jpa.repository.JpaRepository<T,ID>,org.springframework.data.jpa.repository.JpaSpecificationExecutor<T>,org.springframework.data.jpa.repository.support.JpaRepositoryImplementation<T,ID>,org.springframework.data.repository.CrudRepository<T,ID>,org.springframework.data.repository.history.RevisionRepository<T,ID,Integer>,org.springframework.data.repository.PagingAndSortingRepository<T,ID>,org.springframework.data.repository.query.QueryByExampleExecutor<T>,org.springframework.data.repository.Repository<T,ID>
@NoRepositoryBean
public class TemporalRepositoryImpl<T,ID>
extends org.springframework.data.jpa.repository.support.SimpleJpaRepository<T,ID>
implements TemporalRepository<T,ID>
Default implementation of the
TemporalRepository interface.
This implementation extends SimpleJpaRepository overriding the required methods so that all save/delete
queries don't remove data from the database and instead use "from" and "to date" attributes to keep track of what's
been delete and what's current. Find/exist queries are also overridden in order for them to use those same attributes
and return only the current data.
-
Field Summary
Fields inherited from interface dev.claudio.jpatemporal.repository.TemporalRepository
MAX_INSTANT -
Constructor Summary
ConstructorsConstructorDescriptionTemporalRepositoryImpl(org.springframework.data.jpa.repository.support.JpaEntityInformation<T,ID> entityInformation, javax.persistence.EntityManager em) -
Method Summary
Modifier and TypeMethodDescriptionlongcount()longReturns the number of entities available at the givenasOfInstant.longReturns the number of instances that the givenSpecificationwill return at the givenasOfInstant.voidvoiddeleteAllByIdInBatch(Iterable<ID> ids)voidvoiddeleteAllInBatch(Iterable<T> entities)voiddeleteById(ID id)protected intdeleteById(ID id, Instant currentTime)protected intdeleteByIds(Set<ID> ids, Instant currentTime)voiddeleteInBatch(Iterable<T> entities)Deprecated.booleanexistsById(ID id)Returns all instances of the typeTat the givenasOfInstant.Returns all entities matching the givenSpecificationat the givenasOfInstant.findAllById(Iterable<ID> ids)findAllById(Iterable<ID> ids, Instant asOfInstant)Returns all instances of the typeTwith the givenidsat the givenasOfInstant.*************************************************************************************************************** ********************************** JpaRepository ******************************************************************************************************************************************************************************************************************************* ********************************** TemporalRepository ****************************************************************************************************************findLastChangeRevision(ID id)*************************************************************************************************************** ********************************** RevisionRepository ****************************************************************************************************************findRevision(ID id, Integer revisionNumber)findRevisions(ID id)findRevisions(ID id, org.springframework.data.domain.Pageable pageable)findRevisionsList(ID id)getCountQuery(org.springframework.data.jpa.domain.Specification<S> spec, Class<S> domainClass)protected IDgetIdFromEntity(T entity)*************************************************************************************************************** ********************************** Other non-overridden methods *****************************************************************************************************************Deprecated.protected <S extends T>
javax.persistence.TypedQuery<S>getQuery(org.springframework.data.jpa.domain.Specification<S> spec, Class<S> domainClass, org.springframework.data.domain.Sort sort)protected javax.persistence.criteria.PredicateinIdPredicate(Iterable<ID> ids, javax.persistence.criteria.Root<? extends T> root, javax.persistence.criteria.CriteriaBuilder criteriaBuilder)protected org.springframework.data.jpa.domain.Specification<T>*************************************************************************************************************** ********************************** Predicates and Specifications *****************************************************************************************************************<S extends T>
Ssave(S entity)protected javax.persistence.criteria.PredicatetoAndFromPredicate(Instant asOfInstant, javax.persistence.criteria.Root<? extends T> root, javax.persistence.criteria.CriteriaBuilder criteriaBuilder)protected org.springframework.data.jpa.domain.Specification<T>toAndFromSpecification(Instant asOfInstant)Methods inherited from class org.springframework.data.jpa.repository.support.SimpleJpaRepository
count, count, deleteAll, deleteAll, deleteAllById, exists, findAll, findAll, findAll, findAll, findAll, findAll, findAll, findAll, findAll, findOne, findOne, flush, getById, getCountQuery, getDomainClass, getQuery, getQuery, getQuery, getQueryHints, getRepositoryMethodMetadata, readPage, readPage, saveAll, saveAllAndFlush, saveAndFlush, setEscapeCharacter, setRepositoryMethodMetadataMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.data.repository.CrudRepository
deleteAll, deleteAll, deleteAllByIdMethods inherited from interface org.springframework.data.jpa.repository.JpaRepository
findAll, findAll, findAll, findAll, flush, getById, saveAll, saveAllAndFlush, saveAndFlushMethods inherited from interface org.springframework.data.jpa.repository.JpaSpecificationExecutor
count, findAll, findAll, findAll, findOneMethods inherited from interface org.springframework.data.repository.PagingAndSortingRepository
findAllMethods inherited from interface org.springframework.data.repository.query.QueryByExampleExecutor
count, exists, findAll, findOne
-
Constructor Details
-
TemporalRepositoryImpl
-
-
Method Details
-
findById
*************************************************************************************************************** ********************************** TemporalRepository ****************************************************************************************************************- Specified by:
findByIdin interfaceTemporalRepository<T,ID>- Parameters:
id- must not be null.asOfInstant- must not be null.- Returns:
- the entity with the given id or Optional#empty() if none found.
-
findAllById
Description copied from interface:TemporalRepositoryReturns all instances of the typeTwith the givenidsat the givenasOfInstant.If some or all ids are not found, no entities are returned for these IDs.
Note that the order of elements in the result is not guaranteed.
- Specified by:
findAllByIdin interfaceTemporalRepository<T,ID>- Parameters:
ids- must not be null nor contain any null values.asOfInstant- can be null in which case all of the audit related toidsare returned.- Returns:
- guaranteed to be not null. The size can be equal or less than the number of given ids.
-
findAll
Description copied from interface:TemporalRepositoryReturns all instances of the typeTat the givenasOfInstant.- Specified by:
findAllin interfaceTemporalRepository<T,ID>- Parameters:
asOfInstant- must not be null.- Returns:
- all entities
-
findAll
public List<T> findAll(org.springframework.data.jpa.domain.Specification<T> spec, @NonNull Instant asOfInstant)Description copied from interface:TemporalRepositoryReturns all entities matching the givenSpecificationat the givenasOfInstant.- Specified by:
findAllin interfaceTemporalRepository<T,ID>- Parameters:
spec- can be null.asOfInstant- must not be null.- Returns:
- never null.
-
count
Description copied from interface:TemporalRepositoryReturns the number of entities available at the givenasOfInstant.- Specified by:
countin interfaceTemporalRepository<T,ID>- Parameters:
asOfInstant- must not be null.- Returns:
- the number of entities.
-
count
public long count(org.springframework.data.jpa.domain.Specification<T> spec, @NonNull Instant asOfInstant)Description copied from interface:TemporalRepositoryReturns the number of instances that the givenSpecificationwill return at the givenasOfInstant.- Specified by:
countin interfaceTemporalRepository<T,ID>- Parameters:
spec- theSpecificationto count instances for. Can be null.asOfInstant- must not be null.- Returns:
- the number of instances.
-
findById
*************************************************************************************************************** ********************************** JpaRepository **************************************************************************************************************** -
existsById
-
findAllById
- Specified by:
findAllByIdin interfaceorg.springframework.data.repository.CrudRepository<T,ID>- Specified by:
findAllByIdin interfaceorg.springframework.data.jpa.repository.JpaRepository<T,ID>- Overrides:
findAllByIdin classorg.springframework.data.jpa.repository.support.SimpleJpaRepository<T,ID>
-
getOne
Deprecated. -
count
public long count() -
save
-
deleteById
-
delete
-
deleteAllInBatch
public void deleteAllInBatch() -
deleteAllInBatch
-
deleteAllByIdInBatch
-
deleteInBatch
Deprecated. -
getQuery
-
getCountQuery
-
findLastChangeRevision
@NonNull public Optional<org.springframework.data.history.Revision<Integer,T>> findLastChangeRevision(@NonNull ID id)*************************************************************************************************************** ********************************** RevisionRepository **************************************************************************************************************** -
findRevisions
-
findRevisions
-
findRevision
-
inIdSpec
@NonNull protected org.springframework.data.jpa.domain.Specification<T> inIdSpec(@NonNull Iterable<ID> ids)*************************************************************************************************************** ********************************** Predicates and Specifications ***************************************************************************************************************** -
inIdPredicate
-
toAndFromSpecification
-
toAndFromPredicate
-
getIdFromEntity
*************************************************************************************************************** ********************************** Other non-overridden methods ***************************************************************************************************************** -
deleteById
-
deleteByIds
-
findRevisionsList
-