Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Java 8 Stream on JpaSpecificationExecutor with @QueryHint fetchSize support [DATAJPA-1438] #1752

Closed
spring-projects-issues opened this issue Oct 13, 2018 · 2 comments
Assignees
Labels
in: core Issues in core support status: declined A suggestion or change that we don't feel we should currently apply type: enhancement A general enhancement

Comments

@spring-projects-issues
Copy link

László Csatlós opened DATAJPA-1438 and commented

Actual method findAll(Specification<T> spec) on interface JpaSpecificationExecutor<T> can return only with List or Page but not with Stream<T>.

This would be useful for huge resultSets combined with @QueryHint(name="org.hibernate.fetchSize", value="50" ) to truly benefit the power of streaming concept and not to exhaust all of the JVM memory. Hibernate already has the capability to do this with ScrollableResults:

Query query = session.createQuery(query);
query.setReadOnly(true);
query.setFetchSize(100);
ScrollableResults results = query.scroll(ScrollMode.FORWARD_ONLY);

If ambiguous method name is a problem (mentioned at DATAJPA-906), then a
Stream<T> streamAll(Specification<T> spec, Long fetchSize)
signiture would also perfect


2 votes, 3 watchers

@gregturn
Copy link
Contributor

Simply put, we don't plan on adding other permutations of the JpaRepository based on alternative return types, like Stream.

If you wish to have an alternative base repository, Spring Data supports this concept. If you look at https://docs.spring.io/spring-data/jpa/docs/current/reference/html/#repositories.definition, it shows how to define your own base repository.

An alternative is to you the fluent API we added as shown in #2274.

@gregturn gregturn added the status: declined A suggestion or change that we don't feel we should currently apply label Jun 28, 2022
@gregturn
Copy link
Contributor

BONUS: Spring Data JPA, in fact, supports ScrollableResult outputs through its PersistenceProvider.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core support status: declined A suggestion or change that we don't feel we should currently apply type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

3 participants