@Repository
public interface SiteRiskRepository extends JpaRepository<SiteRisk, Long> {
@Query(value="SELECT DATE_TRUNC('day',updated_on)+date_part('hour',updated_on)::int/2 * INTERVAL '2 hour',avg(risk_value) FROM site_risk_tbl WHERE updated_on BETWEEN :fromDate AND :toDate and site_id = :siteId group by 1 order by 1",nativeQuery = true)
public List<AggttRisk> getSiteRiskTrend(@Param("siteId") String siteId, @Param("fromDate") Date fromDate,
@Param("toDate") Date toDate);
}
//projection class
public interface AggttRisk {
String getRiskValue();
String getUpdatedOn();
}
Giving me error:
nested exception is java.lang.IllegalArgumentException: org.hibernate.QueryException: Not all named parameters have been set: [:int] [SELECT DATE_TRUNC('day',updated_on)+date_part('hour',updated_on)::int/2 * INTERVAL '2 hour',avg(risk_value) FROM site_risk_tbl WHERE updated_on BETWEEN :fromDate AND :toDate and site_id = :siteId group by 1 order by 1]]
P.S.: the query works fine while fired on pgadmin.