-
Notifications
You must be signed in to change notification settings - Fork 101
Description
Redis OM Spring is not properly implementing the limiting functionality from Spring Data's PartTree. The findTop2ByOrderByYearFoundedAsc method is returning
all 3 results instead of limiting to 2.
Summary
After investigating the codebase and running tests, I can confirm that findTop1ByTeamOrderByDueDateAsc is NOT actually supported in Redis OM Spring as expected. Here's what I found:
- Missing Implementation: Redis OM Spring's RediSearchQuery class creates a PartTree from the method name but never checks pt.isLimiting() or pt.getMaxResults() to extract the limit value from
method names like findTop, findFirst, or findTop[N]. - Current Behavior: Methods like findTopByTeamOrderByDueDateAsc or findTop1ByTeamOrderByDueDateAsc will execute but will use the default limit from
redisOMProperties.getRepository().getQuery().getLimit(), which defaults to 10,000. - Test Evidence: The test I created shows that findTop2ByOrderByYearFoundedAsc returns all 3 records instead of limiting to 2, confirming the functionality is not implemented.
- Workarounds Available:
- Use @query annotation with @limit
- Use Pageable with PageRequest.of(0, 1)
- Use Entity Streams with .limit(1)
The issue is in the processPartTree method in RediSearchQuery.java which needs to be enhanced to check for limiting:
// This needs to be added after line 382 in processPartTree method:
if (pt.isLimiting()) {
this.limit = pt.getMaxResults().orElse(1);
}
This is a missing feature in Redis OM Spring that should be implemented to fully support Spring Data's query derivation capabilities.