@electronic{vladmihalcea.com, title = {The best way to use Spring Data JPA Stream methods - Vlad Mihalcea}, url = {https://vladmihalcea.com/spring-data-jpa-stream/}, biburl = {https://www.bibsonomy.org/url/882222e5cf39b4ddf68ce312663318a2/jil}, keywords = {bach data hint mysql postgres return size spring stream type}, added-at = {2023-10-25T16:30:13.000+0200}, description = {@Repository public interface PostRepository extends BaseJpaRepository { @Query(""" select p from Post p where date(p.createdOn) >= :sinceDate """ ) @QueryHints( @QueryHint(name = AvailableHints.HINT_FETCH_SIZE, value = "25") ) Stream 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.}, interhash = {882222e5cf39b4ddf68ce312663318a2}, intrahash = {882222e5cf39b4ddf68ce312663318a2} }