-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
BadJpqlGrammarException on left join #3168
Comments
Confirmed as failing on JPQL (works for HQL). |
Okay, the problem appears to be that the query is illegal in pure JPQL.
In the grammar rules for JPQL, the first part of the
Now these aren't my rules. They can be found in the grammar for JPQL at https://jakarta.ee/specifications/persistence/3.1/jakarta-persistence-spec-3.1.html#bnf ...
You can see the We haven't built a counterpart for EQL yet because we A) haven't had the resources to invest in that yet and B) haven't had a lot of feedback from the community as needing that extension yet. I have done preliminary digging and not found much in documentation to guide me on what extensions to the grammar are even needed regarding EQL. (HQL has gobs of examples in their own documentation I turned into acceptance tests.) |
@gregturn Thank you for this thorough investigation. I didn't think about looking at the JPA spec, but you're aboslutely right, it's invalid. |
Right now, using An alternative solution is to leverage custom implementations (check out https://docs.spring.io/spring-data/jpa/docs/current/reference/html/#repositories.custom-implementations for more details on how to hook such a solution into your repository.)...or to rewrite your queries based upon JPQL standards. I don't know the scope of this task. If we're talking a single query failing because of this situation, then a rewrite may possibly fix it. But if we're talking 100 queries, then that option becomes non-effective. It's also possible you are leaning on some of extension found in EQL (see https://eclipse.dev/eclipselink/documentation/3.0/jpa/extensions/jpql.htm) that will NOT be supported by JPQL. I'm more-so talking about custom functions and what not compared to a simple alias in this example. In the meantime, I've opened #3170 to track implemented support for EQL's extension. |
@gregturn Thanks again for raising that second ticket for EQL support (although I understand that without resourcse nor requests from the community, this doesn't get prioritized). |
If it's any consolation, I already started implementing the EQL query parser. Managed to find one of their documents with a LOT of sample queries to craft acceptance tests, and your query up above already works with that parser (even though several other well-documented features don't, yet). |
Since this is being tracked on #3170, I'm closing this ticket. Please following on the other one to track progress. |
When executing the following query on a Repository, spring-data fails with the following error message:
select e from Employee e left join Department d on e.id = d.id where d.name is null or d.name = 'foo'
The text was updated successfully, but these errors were encountered: