Skip to content

[FEATURE REQUEST] Add native support for Stream<T> from JpaSpecificationExecutor #3900

Open
@djechelon

Description

@djechelon

I know the topic has been already discussed

Desiderata
Provide out-of-the-box method to return a Stream from a Specification query, e.g.

    /**
     * Returns all entities matching the given {@link Specification} as a {@link Stream}.
     * <p>
     * If no {@link Specification} is given all entities matching {@code <T>} will be selected.
     *
     * @param spec can be {@literal null}.
     * @return never {@literal null}.
     */
    Stream<T> streamAll(@Nullable Specification<T> spec);
 
    /**
     * Returns all entities matching the given {@link Specification} and {@link Sort} as a {@link Stream}.
     * <p>
     * If no {@link Specification} is given all entities matching {@code <T>} will be selected.
     *
     * @param spec can be {@literal null}.
     * @param sort must not be {@literal null}.
     * @return never {@literal null}.
     */
    Stream<T> streamAll(@Nullable Specification<T> spec, Sort sort);

I have read past tickets like #1261, #1752, #3703

For the first two, I understand that they are dated and in the "old times" 1261 was not feasible to be compatible with Java < 8. But now that we are in the Java 17 era, those comments are out of date.

Now, I do understand that in 3703 there is an issue mentioned with Hibernate.

I would still like to reopen discussion in 2025, even while I do understand that the findBy workaround is applicable.

It would be a simple addition to the SimpleJpaRepositoryImpl. Simple... until we fix the issue with Hibernate (for which I will be posting a comment on 3703)

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: feedback-reminderWe've sent a reminder that we need additional information before we can continuestatus: waiting-for-feedbackWe need additional information before we can continuestatus: waiting-for-triageAn issue we've not yet triaged

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions