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>
Command repository.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe query used to find commands that are in a certain status, not used in jobs and created some time ago. -
Method Summary
Modifier and TypeMethodDescriptionfindUnusedCommandsByStatusesCreatedBefore(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.getCommandDto(String id) Find the command with the given id but also eagerly load all data needed for a command DTO.intsetStatusWhereIdIn(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, saveMethods inherited from interface com.netflix.genie.web.data.services.impl.jpa.repositories.JpaBaseRepository
deleteByIdIn, existsByUniqueId, findByUniqueId, findByUniqueIdMethods 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
-
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 havecommandIds- 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 unusedcommandCreatedThreshold- 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
CommandEntitywith its applications data loaded orOptional.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
CommandEntitywith its applications data loaded orOptional.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
CommandEntitywith its criteria data loaded orOptional.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
CommandEntityall DTO data loaded orOptional.empty()if there is no command with the given id
-