I have a query like so:
@Query(nativeQuery = true, value = "" +
"SELECT f.name AS name " +
"FROM foo f " +
"WHERE f.date > current_date - INTERVAL :days DAY")
Optional<Object> foo(Integer days);
The problem is that :days
requires single quotes around it.
When I try doing something like this
"WHERE f.date > current_date - INTERVAL '" + ":days" + "' DAY"
or this
"WHERE f.date > current_date - INTERVAL ':days' DAY"
the :days
placeholder does not get escaped.
I am using a Postgres database. Does anyone have a solution to this?
Any help is much appreciated!