Reputation: 1457
How properly use such query with date intervals
@SqlUpdate("delete fromlogin where created < now() - ':days days' :: interval")
void deleteOldLogin(@Bind("days") Period days);
Upvotes: 3
Views: 1145
Reputation: 38526
Jdbi now supports binding the java.time.Duration
type as an interval
: https://github.com/jdbi/jdbi/pull/670
Upvotes: 1
Reputation:
You can't pass the number of days inside an interval constant as a parameter. You need to pass an integer specifying your number of days, then multiply that with an interval of the desired length.
@SqlUpdate("delete fromlogin where created < now() - :days * '1 day'::interval")
Upvotes: 8