Interface SnapshotRepository
- All Superinterfaces:
org.springframework.data.repository.CrudRepository<org.qubership.integration.platform.catalog.persistence.configs.entity.chain.Snapshot,,String> org.springframework.data.jpa.repository.JpaRepository<org.qubership.integration.platform.catalog.persistence.configs.entity.chain.Snapshot,,String> org.springframework.data.repository.ListCrudRepository<org.qubership.integration.platform.catalog.persistence.configs.entity.chain.Snapshot,,String> org.springframework.data.repository.ListPagingAndSortingRepository<org.qubership.integration.platform.catalog.persistence.configs.entity.chain.Snapshot,,String> org.springframework.data.repository.PagingAndSortingRepository<org.qubership.integration.platform.catalog.persistence.configs.entity.chain.Snapshot,,String> org.springframework.data.repository.query.QueryByExampleExecutor<org.qubership.integration.platform.catalog.persistence.configs.entity.chain.Snapshot>,org.springframework.data.repository.Repository<org.qubership.integration.platform.catalog.persistence.configs.entity.chain.Snapshot,,String> org.qubership.integration.platform.catalog.persistence.configs.repository.chain.SnapshotBaseRepository
@Repository
public interface SnapshotRepository
extends org.qubership.integration.platform.catalog.persistence.configs.repository.chain.SnapshotBaseRepository
-
Method Summary
Modifier and TypeMethodDescriptionvoiddeleteAllByChainId(String chainId) List<org.qubership.integration.platform.catalog.persistence.configs.entity.chain.Snapshot> findAllByChainId(String chainId) List<org.qubership.integration.platform.catalog.persistence.configs.entity.chain.Snapshot> findAllLastCreated(Collection<String> chainIds) Optional<org.qubership.integration.platform.catalog.persistence.configs.entity.chain.Snapshot> findFirstByChainOrderByIdDesc(org.qubership.integration.platform.catalog.persistence.configs.entity.chain.Chain chain) Optional<org.qubership.integration.platform.catalog.persistence.configs.entity.chain.Snapshot> findSnapshotByChainAndName(org.qubership.integration.platform.catalog.persistence.configs.entity.chain.Chain chain, String name) getNextAvailableName(String chainId) pruneByCreatedWhen(Timestamp createdWhen, int chunk) 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
-
pruneByCreatedWhen
@Query(nativeQuery=true, value="DELETE FROM {h-schema}snapshots where ctid in\n(SELECT s.ctid\nFROM {h-schema}snapshots s\nLEFT JOIN {h-schema}deployments d ON d.snapshot_id = s.id\nLEFT JOIN {h-schema}chains c ON c.current_snapshot_id = s.id\nWHERE s.created_when < :createdWhen AND\nd.id IS NULL AND c.id IS NULL\nLIMIT :chunk) RETURNING id, name, chain_id as chain") List<Map<String,String>> pruneByCreatedWhen(@NonNull Timestamp createdWhen, int chunk) -
findAllByChainId
-
findFirstByChainOrderByIdDesc
Optional<org.qubership.integration.platform.catalog.persistence.configs.entity.chain.Snapshot> findFirstByChainOrderByIdDesc(org.qubership.integration.platform.catalog.persistence.configs.entity.chain.Chain chain) -
deleteAllByChainId
-
getNextAvailableName
@Query(nativeQuery=true, value="select \'V\' || (max(val) + 1)\nFROM (\n select num as val\n from (\n select CAST(replace(name, \'V\', \'\') AS INTEGER) num\n from {h-schema}snapshots\n where chain_id = :chainId\n and name ~ \'V[0-9]+$\'\n order by CAST(replace(name, \'V\', \'\')AS INTEGER) desc\n LIMIT 1\n ) t2\n union all\n select count(name) as val\n from {h-schema}snapshots as t1\n where chain_id = :chainId\n) t") String getNextAvailableName(String chainId) -
findSnapshotByChainAndName
-
findAllLastCreated
@Query(value=" SELECT s.*\n FROM (SELECT chain_id as chain_id, id as snapshot_id, row_number() over(partition by chain_id order by created_when desc) as rn\n FROM catalog.snapshots) AS rns LEFT JOIN catalog.snapshots s ON s.id = rns.snapshot_id\n WHERE rns.chain_id IN (:chainIds) AND rn = 1\n", nativeQuery=true) List<org.qubership.integration.platform.catalog.persistence.configs.entity.chain.Snapshot> findAllLastCreated(Collection<String> chainIds)
-