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

    Fields
    Modifier and Type
    Field
    Description
    static final String
    This is the query used to find the ids of tags that aren't referenced by any of the other tables.
  • Method Summary

    Modifier and Type
    Method
    Description
    Delete all tags from the database whose ids are in the supplied set.
    boolean
    Find out whether a tag entity with the given tag value exists.
    Find a tag by its unique tag value.
    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, save

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

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

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

    count, exists, findAll, findAll, findAll, findOne

    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
  • Field Details

    • SELECT_FOR_UPDATE_UNUSED_TAGS_SQL

      static final String 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

      Optional<TagEntity> findByTag(String tag)
      Find a tag by its unique tag value.
      Parameters:
      tag - The tag value to search for
      Returns:
      An Optional of a TagEntity
    • existsByTag

      boolean existsByTag(String tag)
      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

      Set<TagEntity> findByTagIn(Set<String> tags)
      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. Inclusive
      limit - Maximum number of IDs to return
      Returns:
      The number of tags deleted
    • deleteByIdIn

      @Modifying Long deleteByIdIn(Set<Long> ids)
      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