Closed
Description
I have seen that there are few issues open, that are related to JPQL queries not parsed correctly.
- StringQuery incorrect alias definition for complex native queries [DATAJPA-1613] #1919
- count query fails to be auto generated when using @Query annotation with fetch join #2348
- Count query removes
distinct
phrase if from part of JPA query contains newline character #2341 - StringQuery incorrect alias definition for hql have join query [DATAJPA-1781] #2074
- Sorting by function result not possible if function contains parameter and Sort.by is used [DATAJPA-1750] #2045
- CountQuery fails to be auto generated when not using explicit alias [DATAJPA-1737] #2032
Since EclipseLink is already present in the project it does not bring in a new dependency.
JPQLParser
is located in org.eclipse.persistence.internal.jpa.parsing.jpql
.
Why use JQPLParser
over the current approach? The current approach uses REGEX and String formatting magic that can be quite hard. A REGEX expression is quite limited and has less power than a full parser that utilizes the power of context free grammars. Using only REGEX is not a good idea since JPQL is not a regular language. Therefore JPQL cannot be represented only using REGEX. (see more here and here why REGEX is not powerful enough).