Reputation: 4240
I have a spring mongo repository with the following method
@Query(value = "{'topicId':{$in: ?0},'ts':{$gt:{$date:?2}, $lte:{$date:?3}}, 'status': {$ne:?4}, 'seen':?1 }")
public Page<NotificationReference> findByTopicIdInAndSeenAndStatusNot(List<String> topicIds, Boolean seen,
Date from, Date to, String status, Pageable pageable);
But the ?2 and ?3 date variables are not resolving to their values. I'm passing a java.util.Date
to the method, how do I get spring to resolve date variables for mongo queries?
Upvotes: 1
Views: 940
Reputation: 688
Not using $date should be enough.
@Query(value = "{'topicId':{$in: ?0},'ts':{$gt:{$date:?2}, $lte:{$date:?3}}, 'status': {$ne:?4}, 'seen':?1 }")
Upvotes: 1