@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, и B. Buxton. Proceedings of the Genetic and Evolutionary
Computation Conference (GECCO-2001), стр. 66--73. San Francisco, California, USA, Morgan Kaufmann, (7-11 July 2001)
W. Langdon, S. Barrett, и B. Buxton. Soft Computing and Industry Recent Applications, стр. 597--608. Springer-Verlag, (10--24 September 2001)Published 2002.
W. Langdon, и B. Buxton. Second International Conference on Multiple Classifier
System, том 2096 из LNCS, стр. 68--77. Cambridge, Springer Verlag, (2-4 July 2001)