Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/main/java/st/orm/demo/imdb/service/BrowseService.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public Window<MovieSummary> scrollGenre(String genreName, String cursor) {
return null;
}
Scrollable<MovieSummary> scrollable = cursor != null
? Scrollable.fromCursor(MovieSummary_.id, cursor)
? Scrollable.of(MovieSummary_.id, PAGE_SIZE).from(cursor)
: Scrollable.of(MovieSummary_.id, PAGE_SIZE);
return movieSummaryRepository.scrollByGenre(genre, scrollable);
});
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/st/orm/demo/imdb/service/SearchService.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,15 @@ public SearchResults search(String query) {
*/
public Window<MovieSummary> scrollMovies(String query, String cursor) {
Scrollable<MovieSummary> scrollable = cursor != null
? Scrollable.fromCursor(MovieSummary_.id, cursor)
? Scrollable.of(MovieSummary_.id, MOVIE_PAGE_SIZE).from(cursor)
: Scrollable.of(MovieSummary_.id, MOVIE_PAGE_SIZE);
return movieSummaryRepository.searchByTitle(query, scrollable);
}

/** The next window of person results — same cursor contract as {@link #scrollMovies}. */
public Window<PersonSummary> scrollPersons(String query, String cursor) {
Scrollable<PersonSummary> scrollable = cursor != null
? Scrollable.fromCursor(PersonSummary_.id, cursor)
? Scrollable.of(PersonSummary_.id, PERSON_PAGE_SIZE).from(cursor)
: Scrollable.of(PersonSummary_.id, PERSON_PAGE_SIZE);
return personSummaryRepository.searchByName(query, scrollable);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ void searchByTitleScrollsThroughWindowsWithACursor(ORMTemplate orm, SqlCapture c
assertNotNull(cursor);

Window<MovieSummary> secondWindow = capture.execute(() ->
movieSummaryRepository.searchByTitle("matrix", Scrollable.fromCursor(MovieSummary_.id, cursor)));
movieSummaryRepository.searchByTitle("matrix", Scrollable.of(MovieSummary_.id, 1).from(cursor)));
TestSupport.printStatements(capture, "searchByTitle-cursor");
assertEquals(1, secondWindow.content().size());
assertFalse(firstWindow.content().get(0).id().equals(secondWindow.content().get(0).id()));
Expand Down Expand Up @@ -100,7 +100,7 @@ void scrollByGenreJoinsTheJunctionTableAndScrollsOnTheMovieKey(ORMTemplate orm,
assertTrue(firstWindow.hasNext());

Window<MovieSummary> secondWindow = movieSummaryRepository.scrollByGenre(
drama, Scrollable.fromCursor(MovieSummary_.id, firstWindow.nextCursor()));
drama, Scrollable.of(MovieSummary_.id, 2).from(firstWindow.nextCursor()));
// Three drama movies in total: 2 in the first window, 1 in the second.
assertEquals(1, secondWindow.content().size());
}
Expand Down