Interface JpaTagRepository
- All Superinterfaces:
org.springframework.data.repository.CrudRepository<TagEntity,,Long> org.springframework.data.jpa.repository.JpaRepository<TagEntity,,Long> org.springframework.data.jpa.repository.JpaSpecificationExecutor<TagEntity>,org.springframework.data.repository.PagingAndSortingRepository<TagEntity,,Long> org.springframework.data.repository.query.QueryByExampleExecutor<TagEntity>,org.springframework.data.repository.Repository<TagEntity,Long>
public interface JpaTagRepository
Repository for tags.
- Since:
- 3.3.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThis is the query used to find the ids of tags that aren't referenced by any of the other tables. -
Method Summary
Modifier and TypeMethodDescriptiondeleteByIdIn(Set<Long> ids) Delete all tags from the database whose ids are in the supplied set.booleanexistsByTag(String tag) Find out whether a tag entity with the given tag value exists.Find a tag by its unique tag value.findByTagIn(Set<String> tags) Find tag entities where the tag value is in the given set of tags.findUnusedTags(Instant createdThreshold, int limit) Find all tags from the database that aren't referenced which were created before the supplied created threshold.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, findAll, findAll, findAllById, flush, getById, getOne, getReferenceById, saveAll, saveAllAndFlush, saveAndFlushMethods inherited from interface org.springframework.data.jpa.repository.JpaSpecificationExecutor
count, exists, 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, findBy, findOne
-
Field Details
-
SELECT_FOR_UPDATE_UNUSED_TAGS_SQL
This is the query used to find the ids of tags that aren't referenced by any of the other tables.- See Also:
-
-
Method Details
-
findByTag
Find a tag by its unique tag value.- Parameters:
tag- The tag value to search for- Returns:
- An Optional of a TagEntity
-
existsByTag
Find out whether a tag entity with the given tag value exists.- Parameters:
tag- The tag value to check for- Returns:
- True if the tag exists
-
findByTagIn
Find tag entities where the tag value is in the given set of tags.- Parameters:
tags- The tags to find entities for- Returns:
- The tag entities
-
findUnusedTags
@Query(value="SELECT id FROM tags WHERE id NOT IN (SELECT DISTINCT(tag_id) FROM applications_tags) AND id NOT IN (SELECT DISTINCT(tag_id) FROM clusters_tags) AND id NOT IN (SELECT DISTINCT(tag_id) FROM commands_tags) AND id NOT IN (SELECT DISTINCT(tag_id) FROM criteria_tags) AND id NOT IN (SELECT DISTINCT(tag_id) FROM jobs_tags) AND created <= :createdThreshold LIMIT :limit FOR UPDATE;", nativeQuery=true) Set<Number> findUnusedTags(@Param("createdThreshold") Instant createdThreshold, @Param("limit") int limit) Find all tags from the database that aren't referenced which were created before the supplied created threshold.- Parameters:
createdThreshold- The instant in time where tags created before this time that aren't referenced will be returned. Inclusivelimit- Maximum number of IDs to return- Returns:
- The number of tags deleted
-
deleteByIdIn
Delete all tags from the database whose ids are in the supplied set.- Parameters:
ids- The ids of the tags to delete- Returns:
- The number of tags deleted
-