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

OneToManyDemo: Scroll and collection restrictions #53

Open
minborg opened this issue Sep 4, 2020 · 3 comments
Open

OneToManyDemo: Scroll and collection restrictions #53

minborg opened this issue Sep 4, 2020 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@minborg
Copy link
Contributor

minborg commented Sep 4, 2020

Reproduce: Run OneToManyDemo:

Works:

        Map<Language, Set<Film>> languageFilmMap = jpaStreamer.stream(Language.class)
                .limit(10)
                .collect(
                        toMap(Function.identity(),
                                Language::getFilms)
                );

Fails:

        Map<Language, Set<Film>> languageFilmMap = jpaStreamer.stream(of(Language.class).joining(Language$.films))
                .limit(10)
                .collect(
                        toMap(Function.identity(),
                                Language::getFilms)
                );
@minborg minborg added the bug Something isn't working label Sep 4, 2020
@minborg
Copy link
Contributor Author

minborg commented Sep 4, 2020

This might be a fundamental problem. Joins and skip/limit do not work together. Needs to be handled somehow.

Exception in thread "main" org.hibernate.QueryException: firstResult/maxResults not supported in conjunction with scroll() of a query containing collection fetches
	at org.hibernate.engine.query.spi.HQLQueryPlan.performScroll(HQLQueryPlan.java:350)
	at org.hibernate.internal.SessionImpl.scroll(SessionImpl.java:1554)
	at org.hibernate.query.internal.AbstractProducedQuery.doScroll(AbstractProducedQuery.java:1502)
	at org.hibernate.query.internal.AbstractProducedQuery.scroll(AbstractProducedQuery.java:1488)
	at org.hibernate.query.internal.AbstractProducedQuery.stream(AbstractProducedQuery.java:1512)
	at org.hibernate.query.criteria.internal.compile.CriteriaQueryTypeQueryAdapter.stream(CriteriaQueryTypeQueryAdapter.java:91)
	at org.hibernate.query.Query.getResultStream(Query.java:1140)
	at com.speedment.jpastreamer.renderer.standard.internal.StandardRenderer.render(StandardRenderer.java:88)
	at com.speedment.jpastreamer.builder.standard.internal.StreamBuilder.renderAndThenApply(StreamBuilder.java:361)
	at com.speedment.jpastreamer.builder.standard.internal.StreamBuilder.collect(StreamBuilder.java:218)
	at com.speedment.jpastreamer.autoclose.standard.internal.AutoClosingStream.lambda$collect$7(AutoClosingStream.java:179)
	at com.speedment.jpastreamer.autoclose.standard.internal.AbstractAutoClosingBaseStream.finallyClose(AbstractAutoClosingBaseStream.java:95)
	at com.speedment.jpastreamer.autoclose.standard.internal.AutoClosingStream.collect(AutoClosingStream.java:179)
	at com.speedment.jpastreamer.demo.OneToManyDemo.main(OneToManyDemo.java:32)

@minborg
Copy link
Contributor Author

minborg commented Sep 4, 2020

We could add a parameter in the StreamConfiguration

resolveJoinSkipLimit(JoinSkipLimitResolver joinSkipResolver)

FAIL, FAVOR_JOIN, FAVOR_SKIP_LIMIT

@minborg
Copy link
Contributor Author

minborg commented Sep 16, 2020

This should work by moving the skip to the JVM:

        final StreamConfiguration<Film> configuration = StreamConfiguration.of(Film.class).joining(Film$.actors).joining(Film$.language);

        jpaStreamer.stream(configuration)
                .sorted(Film$.length.reversed())
                .limit(10)
                .forEach(System.out::println);

@minborg minborg added this to the 0.1.8 milestone Sep 16, 2020
@minborg minborg assigned minborg and unassigned dekmm Sep 24, 2020
@minborg minborg modified the milestones: 0.1.8, 0.1.9 Sep 24, 2020
@minborg minborg removed this from the 0.1.9 milestone Dec 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants