public interface JpaCommandRepository extends JpaBaseRepository<CommandEntity>
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
FIND_UNUSED_COMMANDS_QUERY
The query used to find commands that are unused to delete.
|
static java.lang.String |
SET_UNUSED_STATUS_QUERY
The query used to set commands to a given status given input parameters.
|
| Modifier and Type | Method and Description |
|---|---|
java.util.Set<java.lang.Long> |
findUnusedCommands(java.util.Set<java.lang.String> unusedStatuses,
java.time.Instant commandCreatedThreshold,
int limit)
Find commands from the database where their status is in deleteStatuses they were created
before commandCreatedThreshold and they aren't attached to any jobs still in the database.
|
java.util.Optional<CommandEntity> |
getCommandAndApplications(java.lang.String id)
Find the command with the given id but also eagerly load that commands applications.
|
java.util.Optional<CommandEntity> |
getCommandAndApplicationsDto(java.lang.String id)
Find the command with the given id but also eagerly load that commands applications full dto contents.
|
java.util.Optional<CommandEntity> |
getCommandAndClusterCriteria(java.lang.String id)
Find the command with the given id but also eagerly load that commands cluster criteria.
|
java.util.Optional<CommandEntity> |
getCommandDto(java.lang.String id)
Find the command with the given id but also eagerly load all data needed for a command DTO.
|
int |
setUnusedStatus(java.lang.String desiredStatus,
java.time.Instant commandCreatedThreshold,
java.util.Set<java.lang.String> currentStatuses,
java.time.Instant jobCreatedThreshold)
Bulk set the status of commands which match the given inputs.
|
deleteByIdIn, existsByUniqueId, findByUniqueId, findByUniqueIddeleteAllInBatch, deleteInBatch, findAll, findAll, findAll, findAll, findAllById, flush, getOne, saveAll, saveAndFlushfindAllcount, delete, deleteAll, deleteAll, deleteById, existsById, findById, savestatic final java.lang.String SET_UNUSED_STATUS_QUERY
static final java.lang.String FIND_UNUSED_COMMANDS_QUERY
@Query(value="UPDATE commands SET status = :desiredStatus WHERE status IN (:currentStatuses) AND created < :commandCreatedThreshold AND id NOT IN (SELECT DISTINCT(command_id) FROM jobs WHERE command_id IS NOT NULL AND created >= :jobCreatedThreshold)",
nativeQuery=true)
@Modifying
int setUnusedStatus(@Param(value="desiredStatus")
java.lang.String desiredStatus,
@Param(value="commandCreatedThreshold")
java.time.Instant commandCreatedThreshold,
@Param(value="currentStatuses")
java.util.Set<java.lang.String> currentStatuses,
@Param(value="jobCreatedThreshold")
java.time.Instant jobCreatedThreshold)
desiredStatus - The new status the matching commands should havecommandCreatedThreshold - The instant in time which a command must have been created before to be
considered for update. ExclusivecurrentStatuses - The set of current statuses a command must have to be considered for updatejobCreatedThreshold - The instant in time after which a command must not have been used in a Genie job
for it to be considered for update. Inclusive.@Query(value="SELECT id FROM commands WHERE status IN (:unusedStatuses) AND created < :commandCreatedThreshold AND id NOT IN (SELECT DISTINCT(command_id) FROM jobs WHERE command_id IS NOT NULL) LIMIT :limit",
nativeQuery=true)
java.util.Set<java.lang.Long> findUnusedCommands(@Param(value="unusedStatuses")
java.util.Set<java.lang.String> unusedStatuses,
@Param(value="commandCreatedThreshold")
java.time.Instant commandCreatedThreshold,
@Param(value="limit")
int limit)
unusedStatuses - The set of statuses a command must be in in order to be considered unusedcommandCreatedThreshold - The instant in time a command must have been created before to be considered
unused. Exclusive.limit - Maximum number of IDs to return@Query(value="SELECT c FROM CommandEntity c WHERE c.uniqueId = :id")
@EntityGraph(value="Command.applications",
type=LOAD)
java.util.Optional<CommandEntity> getCommandAndApplications(@Param(value="id")
java.lang.String id)
id - The id of the command to getCommandEntity with its applications data loaded or Optional.empty() if there is no
command with the given id@Query(value="SELECT c FROM CommandEntity c WHERE c.uniqueId = :id")
@EntityGraph(value="Command.applications.dto",
type=LOAD)
java.util.Optional<CommandEntity> getCommandAndApplicationsDto(@Param(value="id")
java.lang.String id)
id - The id of the command to getCommandEntity with its applications data loaded or Optional.empty() if there is no
command with the given id@Query(value="SELECT c FROM CommandEntity c WHERE c.uniqueId = :id")
@EntityGraph(value="Command.clusterCriteria",
type=LOAD)
java.util.Optional<CommandEntity> getCommandAndClusterCriteria(@Param(value="id")
java.lang.String id)
id - The id of the command to getCommandEntity with its criteria data loaded or Optional.empty() if there is no
command with the given id@Query(value="SELECT c FROM CommandEntity c WHERE c.uniqueId = :id")
@EntityGraph(value="Command.DTO",
type=LOAD)
java.util.Optional<CommandEntity> getCommandDto(@Param(value="id")
java.lang.String id)
id - The id of the command to getCommandEntity all DTO data loaded or Optional.empty() if there is no
command with the given id