Interface JpaCommandRepository

All Superinterfaces:
org.springframework.data.repository.CrudRepository<CommandEntity,Long>, JpaBaseRepository<CommandEntity>, org.springframework.data.jpa.repository.JpaRepository<CommandEntity,Long>, org.springframework.data.jpa.repository.JpaSpecificationExecutor<CommandEntity>, org.springframework.data.repository.PagingAndSortingRepository<CommandEntity,Long>, org.springframework.data.repository.query.QueryByExampleExecutor<CommandEntity>, org.springframework.data.repository.Repository<CommandEntity,Long>

public interface JpaCommandRepository extends JpaBaseRepository<CommandEntity>
Command repository.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    The query used to find commands that are in a certain status, not used in jobs and created some time ago.
  • Method Summary

    Modifier and Type
    Method
    Description
    findUnusedCommandsByStatusesCreatedBefore(Set<String> statuses, Instant commandCreatedThreshold, int limit)
    Find commands from the database where their status is in statuses and they were created before commandCreatedThreshold and they aren't attached to any jobs still in the database.
    Find the command with the given id but also eagerly load that commands applications.
    Find the command with the given id but also eagerly load that commands applications full dto contents.
    Find the command with the given id but also eagerly load that commands cluster criteria.
    Find the command with the given id but also eagerly load all data needed for a command DTO.
    int
    setStatusWhereIdIn(String desiredStatus, Set<Long> commandIds)
    Bulk set the status of commands which match the given inputs.

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

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

    Methods inherited from interface com.netflix.genie.web.data.services.impl.jpa.repositories.JpaBaseRepository

    deleteByIdIn, existsByUniqueId, findByUniqueId, findByUniqueId

    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

    • FIND_UNUSED_COMMANDS_IN_STATUS_CREATED_BEFORE_QUERY

      static final String FIND_UNUSED_COMMANDS_IN_STATUS_CREATED_BEFORE_QUERY
      The query used to find commands that are in a certain status, not used in jobs and created some time ago.
      See Also:
  • Method Details

    • setStatusWhereIdIn

      @Query("UPDATE CommandEntity c SET c.status = :desiredStatus WHERE c.id IN (:commandIds)") @Modifying int setStatusWhereIdIn(@Param("desiredStatus") String desiredStatus, @Param("commandIds") Set<Long> commandIds)
      Bulk set the status of commands which match the given inputs.
      Parameters:
      desiredStatus - The new status the matching commands should have
      commandIds - The ids which should be updated
      Returns:
      The number of commands that were updated by the query
    • findUnusedCommandsByStatusesCreatedBefore

      @Query(value="SELECT id FROM commands WHERE status IN (:statuses) AND created < :commandCreatedThreshold AND id NOT IN (SELECT DISTINCT(command_id) FROM jobs WHERE command_id IS NOT NULL) LIMIT :limit", nativeQuery=true) Set<Long> findUnusedCommandsByStatusesCreatedBefore(@Param("statuses") Set<String> statuses, @Param("commandCreatedThreshold") Instant commandCreatedThreshold, @Param("limit") int limit)
      Find commands from the database where their status is in statuses and they were created before commandCreatedThreshold and they aren't attached to any jobs still in the database.
      Parameters:
      statuses - The set of statuses a command must be in for it to be considered unused
      commandCreatedThreshold - The instant in time a command must have been created before to be considered unused. Exclusive.
      limit - Maximum number of IDs to return
      Returns:
      The ids of the commands that are considered unused
    • getCommandAndApplications

      @Query("SELECT c FROM CommandEntity c WHERE c.uniqueId = :id") @EntityGraph(value="Command.applications", type=LOAD) Optional<CommandEntity> getCommandAndApplications(@Param("id") String id)
      Find the command with the given id but also eagerly load that commands applications.
      Parameters:
      id - The id of the command to get
      Returns:
      The CommandEntity with its applications data loaded or Optional.empty() if there is no command with the given id
    • getCommandAndApplicationsDto

      @Query("SELECT c FROM CommandEntity c WHERE c.uniqueId = :id") @EntityGraph(value="Command.applications.dto", type=LOAD) Optional<CommandEntity> getCommandAndApplicationsDto(@Param("id") String id)
      Find the command with the given id but also eagerly load that commands applications full dto contents.
      Parameters:
      id - The id of the command to get
      Returns:
      The CommandEntity with its applications data loaded or Optional.empty() if there is no command with the given id
    • getCommandAndClusterCriteria

      @Query("SELECT c FROM CommandEntity c WHERE c.uniqueId = :id") @EntityGraph(value="Command.clusterCriteria", type=LOAD) Optional<CommandEntity> getCommandAndClusterCriteria(@Param("id") String id)
      Find the command with the given id but also eagerly load that commands cluster criteria.
      Parameters:
      id - The id of the command to get
      Returns:
      The CommandEntity with its criteria data loaded or Optional.empty() if there is no command with the given id
    • getCommandDto

      @Query("SELECT c FROM CommandEntity c WHERE c.uniqueId = :id") @EntityGraph(value="Command.DTO", type=LOAD) Optional<CommandEntity> getCommandDto(@Param("id") String id)
      Find the command with the given id but also eagerly load all data needed for a command DTO.
      Parameters:
      id - The id of the command to get
      Returns:
      The CommandEntity all DTO data loaded or Optional.empty() if there is no command with the given id