Package dev.dokimos.server.repository
Interface DatasetVersionRepository
- All Superinterfaces:
org.springframework.data.repository.CrudRepository<DatasetVersion,,UUID> org.springframework.data.jpa.repository.JpaRepository<DatasetVersion,,UUID> org.springframework.data.repository.ListCrudRepository<DatasetVersion,,UUID> org.springframework.data.repository.ListPagingAndSortingRepository<DatasetVersion,,UUID> org.springframework.data.repository.PagingAndSortingRepository<DatasetVersion,,UUID> org.springframework.data.repository.query.QueryByExampleExecutor<DatasetVersion>,org.springframework.data.repository.Repository<DatasetVersion,UUID>
public interface DatasetVersionRepository
extends org.springframework.data.jpa.repository.JpaRepository<DatasetVersion,UUID>
-
Method Summary
Modifier and TypeMethodDescriptionfindByDatasetAndVersion(Dataset dataset, int version) findByDatasetOrderByVersionDesc(Dataset dataset) findLatestPerDataset(List<Dataset> datasets) Returns the latest version row for every supplied dataset in a single query.findMaxVersion(Dataset dataset) Returns the current maximum version number for the dataset, ornullif no versions exist.Methods inherited from interface org.springframework.data.repository.CrudRepository
count, delete, deleteAll, deleteAll, deleteAllById, deleteById, existsById, findById, saveMethods inherited from interface org.springframework.data.jpa.repository.JpaRepository
deleteAllByIdInBatch, deleteAllInBatch, deleteAllInBatch, deleteInBatch, findAll, findAll, flush, getById, getOne, getReferenceById, saveAllAndFlush, saveAndFlushMethods inherited from interface org.springframework.data.repository.ListCrudRepository
findAll, findAllById, saveAllMethods inherited from interface org.springframework.data.repository.ListPagingAndSortingRepository
findAllMethods inherited from interface org.springframework.data.repository.PagingAndSortingRepository
findAllMethods inherited from interface org.springframework.data.repository.query.QueryByExampleExecutor
count, exists, findAll, findBy, findOne
-
Method Details
-
findByDatasetOrderByVersionDesc
-
findFirstByDatasetOrderByVersionDesc
-
findByDatasetAndVersion
-
findMaxVersion
@Query("select max(v.version) from DatasetVersion v where v.dataset = :dataset") Integer findMaxVersion(@Param("dataset") Dataset dataset) Returns the current maximum version number for the dataset, ornullif no versions exist. Callers should hold a pessimistic lock on the dataset row (seeDatasetRepository.findByIdForUpdate) before reading this so thenext = max + 1write cannot race. -
findLatestPerDataset
@Query("select v from DatasetVersion v join fetch v.dataset where v.dataset in :datasets and v.version = (select max(v2.version) from DatasetVersion v2 where v2.dataset = v.dataset)") List<DatasetVersion> findLatestPerDataset(@Param("datasets") List<Dataset> datasets) Returns the latest version row for every supplied dataset in a single query. The dataset is eagerly joined so callers can readversion.getDataset().getId()without triggering a per-row lazy fetch.
-