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

can't leftOuterJoin support subquery? #114

Open
phdbutbachelor opened this issue Dec 22, 2023 · 2 comments
Open

can't leftOuterJoin support subquery? #114

phdbutbachelor opened this issue Dec 22, 2023 · 2 comments

Comments

@phdbutbachelor
Copy link

Hello!
I want to make a query like:

JinqStream<Pair<CommentEvent, User>> _query = stream(CommentEvent.class)
                .leftOuterJoin((i, session) -> session.stream(User.class), (i, j) -> j.getId().equals(i.getCreatorId()));

JinqStream<Pair<Pair<CommentEvent, User>, Pair<String, Long>>> _temp = _query.leftOuterJoin((j, source) -> source.stream(CommentEvent.class)
                                .where(k -> k.getSourceId() != null)
                                .group(k -> k.getSourceId(), (id, stream) -> stream.count()), (j, k) -> j.getOne().getId().equals(k.getOne()));

but throw a exception like 'can't thanslate to code', how to fix it?

@my2iu
Copy link
Owner

my2iu commented Dec 22, 2023

Do you have more extensive exception information? Usually, the exception will have additional information a few levels deeper inside explaining why the code could not be translated. When I just glance over the queries though, grouping queries are not allowed in subqueries (they're special in SQL and JPQL, so they are only supported at the top-level of a query).

@my2iu
Copy link
Owner

my2iu commented Dec 22, 2023

It also looks like, maybe you don't need any subqueries here. One left outer join between CommonEvent and User using CreatorId, then just use a normal join of that to CommonEvent based on SourceId. And then perform your grouping operation on everything afterwards. The subquery doesn't seem to be necessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants