fix(aria): fix os_eol_status enum cast — use native SQL throughout
CD - Develop / build-and-deploy (push) Failing after 14m42s

PostgreSQL named enum types require explicit casts that Hibernate's
derived query methods don't generate. Replace countByOsEolStatus and
findByOsEolStatusOrderByPostureScoreAsc with native @Query variants that
CAST(:status AS os_eol_status). Same pattern already applied to severity.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-15 15:57:41 -04:00
parent 1e7625db8b
commit 89a088c4b3
3 changed files with 9 additions and 7 deletions
@@ -52,7 +52,7 @@ public class DevicePostureController {
Pageable pageable = PageRequest.of(page, size);
if (osEolStatus != null) {
return postureRepository.findByOsEolStatusOrderByPostureScoreAsc(osEolStatus, pageable);
return postureRepository.findByOsEolStatusNativeOrderByPostureScoreAsc(osEolStatus.name(), pageable);
}
if ("low".equals(scoreFilter)) {
return postureRepository.findByPostureScoreLessThanOrderByPostureScoreAsc(50, pageable);
@@ -1,6 +1,5 @@
package com.hiveops.aria.controller;
import com.hiveops.aria.entity.DeviceSecurityPosture;
import com.hiveops.aria.entity.ThreatEvent;
import com.hiveops.aria.repository.DeviceSecurityPostureRepository;
import com.hiveops.aria.repository.PrecursorSequenceAlertRepository;
@@ -57,7 +56,7 @@ public class ThreatEventController {
long activeSequences = sequenceAlertRepository.countByResolvedAtIsNull();
long lowPostureCount = postureRepository.countByPostureScoreLessThan(50);
long eolDeviceCount = postureRepository.countByOsEolStatus(DeviceSecurityPosture.OsEolStatus.EOL);
long eolDeviceCount = postureRepository.countByOsEolStatusNative("EOL");
return ResponseEntity.ok(Map.of(
"totalEvents", totalEvents,
@@ -4,6 +4,8 @@ import com.hiveops.aria.entity.DeviceSecurityPosture;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
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;
@@ -15,13 +17,14 @@ public interface DeviceSecurityPostureRepository extends JpaRepository<DeviceSec
Page<DeviceSecurityPosture> findAllByOrderByPostureScoreAsc(Pageable pageable);
Page<DeviceSecurityPosture> findByOsEolStatusOrderByPostureScoreAsc(
DeviceSecurityPosture.OsEolStatus osEolStatus, Pageable pageable);
Page<DeviceSecurityPosture> findByPostureScoreLessThanOrderByPostureScoreAsc(
int score, Pageable pageable);
long countByPostureScoreLessThan(int score);
long countByOsEolStatus(DeviceSecurityPosture.OsEolStatus osEolStatus);
@Query(value = "SELECT COUNT(*) FROM device_security_posture WHERE os_eol_status = CAST(:status AS os_eol_status)", nativeQuery = true)
long countByOsEolStatusNative(@Param("status") String status);
@Query(value = "SELECT * FROM device_security_posture WHERE os_eol_status = CAST(:status AS os_eol_status) ORDER BY posture_score ASC", nativeQuery = true, countQuery = "SELECT COUNT(*) FROM device_security_posture WHERE os_eol_status = CAST(:status AS os_eol_status)")
Page<DeviceSecurityPosture> findByOsEolStatusNativeOrderByPostureScoreAsc(@Param("status") String status, Pageable pageable);
}