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 Type
    Method
    Description
    findByDatasetAndVersion(Dataset dataset, int version)
     
     
     
    Returns the latest version row for every supplied dataset in a single query.
    Returns the current maximum version number for the dataset, or null if no versions exist.

    Methods inherited from interface org.springframework.data.repository.CrudRepository

    count, delete, deleteAll, deleteAll, deleteAllById, deleteById, existsById, findById, save

    Methods inherited from interface org.springframework.data.jpa.repository.JpaRepository

    deleteAllByIdInBatch, deleteAllInBatch, deleteAllInBatch, deleteInBatch, findAll, findAll, flush, getById, getOne, getReferenceById, saveAllAndFlush, saveAndFlush

    Methods inherited from interface org.springframework.data.repository.ListCrudRepository

    findAll, findAllById, saveAll

    Methods inherited from interface org.springframework.data.repository.ListPagingAndSortingRepository

    findAll

    Methods inherited from interface org.springframework.data.repository.PagingAndSortingRepository

    findAll

    Methods inherited from interface org.springframework.data.repository.query.QueryByExampleExecutor

    count, exists, findAll, findBy, findOne
  • Method Details

    • findByDatasetOrderByVersionDesc

      List<DatasetVersion> findByDatasetOrderByVersionDesc(Dataset dataset)
    • findFirstByDatasetOrderByVersionDesc

      Optional<DatasetVersion> findFirstByDatasetOrderByVersionDesc(Dataset dataset)
    • findByDatasetAndVersion

      Optional<DatasetVersion> findByDatasetAndVersion(Dataset dataset, int version)
    • 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, or null if no versions exist. Callers should hold a pessimistic lock on the dataset row (see DatasetRepository.findByIdForUpdate) before reading this so the next = max + 1 write 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 read version.getDataset().getId() without triggering a per-row lazy fetch.