@Repository
public interface PostRepository extends BaseJpaRepository<Post, Long> {
@Query("""
select p
from Post p
where date(p.createdOn) >= :sinceDate
"""
)
@QueryHints(
@QueryHint(name = AvailableHints.HINT_FETCH_SIZE, value = "25")
)
Stream<Post> streamByCreatedOnSince(@Param("sinceDate") LocalDate sinceDate);
}
The FETCH_SIZE JPA query hint is necessary for PostgreSQL and MySQL to instruct the JDBC Driver to prefetch at most 25 records. Otherwise, the PostgreSQL and MySQL JDBC Drivers would prefetch all the query results prior to traversing the underlying ResultSet.
W. Langdon, S. Barrett, und B. Buxton. Soft Computing and Industry Recent Applications, Seite 597--608. Springer-Verlag, (10--24 September 2001)Published 2002.
W. Langdon, und B. Buxton. Second International Conference on Multiple Classifier
System, Volume 2096 von LNCS, Seite 68--77. Cambridge, Springer Verlag, (2-4 July 2001)
W. Langdon, und B. Buxton. Proceedings of the Genetic and Evolutionary
Computation Conference (GECCO-2001), Seite 66--73. San Francisco, California, USA, Morgan Kaufmann, (7-11 July 2001)