public interface JpaFileRepository
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
SELECT_FOR_UPDATE_UNUSED_FILES_SQL
The query used to select any dangling file references.
|
Modifier and Type | Method and Description |
---|---|
java.lang.Long |
deleteByIdIn(java.util.Set<java.lang.Long> ids)
Delete all files from the database that are in the current set of ids.
|
boolean |
existsByFile(java.lang.String file)
Find out whether a file entity with the given file value exists.
|
java.util.Optional<FileEntity> |
findByFile(java.lang.String file)
Find a file by its unique file value.
|
java.util.Set<FileEntity> |
findByFileIn(java.util.Set<java.lang.String> files)
Find file entities where the file value is in the given set of files.
|
java.util.Set<java.lang.Number> |
findUnusedFiles(java.time.Instant createdThreshold)
Find the ids of all files from the database that aren't referenced which were created before the supplied created
threshold.
|
deleteAllInBatch, deleteInBatch, findAll, findAll, findAll, findAll, findAllById, flush, getOne, saveAll, saveAndFlush
findAll
count, delete, deleteAll, deleteAll, deleteById, existsById, findById, save
static final java.lang.String SELECT_FOR_UPDATE_UNUSED_FILES_SQL
java.util.Optional<FileEntity> findByFile(java.lang.String file)
file
- The file value to search forboolean existsByFile(java.lang.String file)
file
- The file value to check forjava.util.Set<FileEntity> findByFileIn(java.util.Set<java.lang.String> files)
files
- The files to find entities for@Query(value="SELECT id FROM files WHERE id NOT IN (SELECT DISTINCT(setup_file) FROM applications WHERE setup_file IS NOT NULL) AND id NOT IN (SELECT DISTINCT(file_id) FROM applications_configs) AND id NOT IN (SELECT DISTINCT(file_id) FROM applications_dependencies) AND id NOT IN (SELECT DISTINCT(setup_file) FROM clusters WHERE setup_file IS NOT NULL) AND id NOT IN (SELECT DISTINCT(file_id) FROM clusters_configs) AND id NOT IN (SELECT DISTINCT(file_id) FROM clusters_dependencies) AND id NOT IN (SELECT DISTINCT(setup_file) FROM commands WHERE setup_file IS NOT NULL) AND id NOT IN (SELECT DISTINCT(file_id) FROM commands_configs) AND id NOT IN (SELECT DISTINCT(file_id) FROM commands_dependencies) AND id NOT IN (SELECT DISTINCT(setup_file) FROM jobs WHERE setup_file IS NOT NULL) AND id NOT IN (SELECT DISTINCT(file_id) FROM jobs_configs) AND id NOT IN (SELECT DISTINCT(file_id) FROM jobs_dependencies) AND created <= :createdThreshold FOR UPDATE;", nativeQuery=true) java.util.Set<java.lang.Number> findUnusedFiles(@Param(value="createdThreshold") java.time.Instant createdThreshold)
createdThreshold
- The instant in time where files created before this time that aren't referenced
will be selected. Inclusive.@Modifying java.lang.Long deleteByIdIn(java.util.Set<java.lang.Long> ids)
ids
- The unique ids of the files to delete