Skip to content

Commit

Permalink
Tmi2 402/fix integer conversion (#79)
Browse files Browse the repository at this point in the history
* change sql, and cast the integer value

* fix casting error
  • Loading branch information
a-lor-cab authored Nov 17, 2023
1 parent 9b5ce35 commit 1ebd4ab
Showing 1 changed file with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import gov.cabinetoffice.gap.adminbackend.enums.SpotlightBatchStatus;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.Optional;
Expand All @@ -13,11 +12,10 @@
@Repository
public interface SpotlightBatchRepository extends JpaRepository<SpotlightBatch, UUID> {

@Query(value = "SELECT (count(s) > 0) FROM SpotlightBatch s WHERE s.status = :status AND SIZE(s.spotlightSubmissions) < CAST(:maxSize AS INTEGER)")
Boolean existsByStatus(@Param("status") SpotlightBatchStatus status, @Param("maxSize") int maxSize);
@Query("select (count(s) > 0) from SpotlightBatch s where s.status = ?1 AND SIZE(s.spotlightSubmissions) < CAST(?2 AS int)")
Boolean existsByStatus(SpotlightBatchStatus status, int maxSize);

@Query(value = "SELECT sb FROM SpotlightBatch sb WHERE sb.status = :status AND SIZE(sb.spotlightSubmissions) < CAST(:maxSize AS INTEGER)")
Optional<SpotlightBatch> findByStatusAndSpotlightSubmissionsSizeLessThan(
@Param("status") SpotlightBatchStatus status, @Param("maxSize") int maxSize);
@Query("SELECT sb FROM SpotlightBatch sb WHERE sb.status = ?1 AND SIZE(sb.spotlightSubmissions) < CAST(?2 AS int)")
Optional<SpotlightBatch> findByStatusAndSpotlightSubmissionsSizeLessThan(SpotlightBatchStatus status, int maxSize);

}

0 comments on commit 1ebd4ab

Please sign in to comment.