'How to pass named parameter value into MySQL function using @Query() in Spring Data JPA?

@Query(value = "select * from reports where timeStamp < date_sub(:now, interval :interval) order by ID", nativeQuery = true)
public List<Report> getReportsByInterval(@Param("now") String now, @Param("interval") String interval);

How to pass timestamp and interval string (For example: "1 day") into mysql date_sub() function using named parameter and @Query annotation? I used above code, but it doesn't seem to work.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source