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

NEW as a part of a state field path expression in JPQL. #3128

Closed
wilx opened this issue Aug 28, 2023 · 4 comments
Closed

NEW as a part of a state field path expression in JPQL. #3128

wilx opened this issue Aug 28, 2023 · 4 comments
Assignees
Labels
in: query-parser Everything related to parsing JPQL or SQL status: feedback-provided Feedback has been provided type: regression A regression from a previous release

Comments

@wilx
Copy link

wilx commented Aug 28, 2023

We have updated from 2022.0.6 to 2023.0.2 and we are getting BadJpqlGrammarException on the following query:

SELECT j FROM AgentUpdateTask j WHERE j.creationTimestamp < :date AND (j.status=com.ca.apm.acc.configserver.core.domain.jobs.AgentUpdateTaskStatus.NEW OR      j.status=com.ca.apm.acc.configserver.core.domain.jobs.AgentUpdateTaskStatus.STARTED OR      j.status=com.ca.apm.acc.configserver.core.domain.jobs.AgentUpdateTaskStatus.QUEUED) ORDER BY j.id

It does not seem to like the j.creationTimestamp < :date. The same query worked fine before the update.

The tail of the exception trace:

Caused by: org.springframework.data.jpa.repository.query.BadJpqlGrammarException: Line 1:61 no viable alternative at input 'j.creationTimestamp<:date'; Bad JPQL grammar [SELECT j FROM AgentUpdateTask j WHERE j.creationTimestamp < :date AND (j.status=com.ca.apm.acc.configserver.core.domain.jobs.AgentUpdateTaskStatus.NEW OR      j.status=com.ca.apm.acc.configserver.core.domain.jobs.AgentUpdateTaskStatus.STARTED OR      j.status=com.ca.apm.acc.configserver.core.domain.jobs.AgentUpdateTaskStatus.QUEUED) ORDER BY j.id]
	at org.springframework.data.jpa.repository.query.BadJpqlGrammarErrorListener.syntaxError(BadJpqlGrammarErrorListener.java:39)
	at org.antlr.v4.runtime.ProxyErrorListener.syntaxError(ProxyErrorListener.java:41)
	at org.antlr.v4.runtime.Parser.notifyErrorListeners(Parser.java:543)
	at org.antlr.v4.runtime.DefaultErrorStrategy.reportNoViableAlternative(DefaultErrorStrategy.java:310)
	at org.antlr.v4.runtime.DefaultErrorStrategy.reportError(DefaultErrorStrategy.java:136)
	at org.springframework.data.jpa.repository.query.JpqlParser.comparison_expression(JpqlParser.java:6148)
	at org.springframework.data.jpa.repository.query.JpqlParser.simple_cond_expression(JpqlParser.java:4704)
	at org.springframework.data.jpa.repository.query.JpqlParser.conditional_primary(JpqlParser.java:4622)
	at org.springframework.data.jpa.repository.query.JpqlParser.conditional_factor(JpqlParser.java:4571)
	at org.springframework.data.jpa.repository.query.JpqlParser.conditional_term(JpqlParser.java:4490)
	at org.springframework.data.jpa.repository.query.JpqlParser.conditional_expression(JpqlParser.java:4406)
	at org.springframework.data.jpa.repository.query.JpqlParser.where_clause(JpqlParser.java:3103)
	at org.springframework.data.jpa.repository.query.JpqlParser.select_statement(JpqlParser.java:397)
	at org.springframework.data.jpa.repository.query.JpqlParser.ql_statement(JpqlParser.java:310)
	at org.springframework.data.jpa.repository.query.JpqlParser.start(JpqlParser.java:254)
	at org.springframework.data.jpa.repository.query.JpqlQueryParser.parseQuery(JpqlQueryParser.java:53)
	at org.springframework.data.jpa.repository.query.JpqlQueryParser.parse(JpqlQueryParser.java:64)
	at org.springframework.data.jpa.repository.query.JpaQueryParserSupport$ParseState.lambda$new$0(JpaQueryParserSupport.java:182)
	at org.springframework.data.util.Lazy.getNullable(Lazy.java:245)
	at org.springframework.data.util.Lazy.get(Lazy.java:114)
	at org.springframework.data.jpa.repository.query.JpaQueryParserSupport$ParseState.getContext(JpaQueryParserSupport.java:194)
	at org.springframework.data.jpa.repository.query.JpaQueryParserSupport.renderSortedQuery(JpaQueryParserSupport.java:54)
	... 101 common frames omitted
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Aug 28, 2023
@mp911de mp911de added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged labels Aug 28, 2023
@gregturn gregturn added type: regression A regression from a previous release in: query-parser Everything related to parsing JPQL or SQL and removed type: bug A general bug labels Aug 28, 2023
@gregturn gregturn added this to the 3.1.4 (2023.0.4) milestone Aug 28, 2023
@gregturn
Copy link
Contributor

Query works fine with the HQL parser. Looks like this is a JPQL parser issue. Can you confirm you are NOT using Hibernate? And if that is the case, what JPA provider are you using?

@gregturn gregturn added the status: waiting-for-feedback We need additional information before we can continue label Aug 28, 2023
@wilx
Copy link
Author

wilx commented Aug 28, 2023

Query works fine with the HQL parser. Looks like this is a JPQL parser issue. Can you confirm you are NOT using Hibernate? And if that is the case, what JPA provider are you using?

We are not using Hibernate. We are using EclipseLink 4.0.2.

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Aug 28, 2023
@gregturn
Copy link
Contributor

gregturn commented Aug 28, 2023

Okay, DATE as a token was patched in #3092 and released with Spring Data JPA 3.2.0-M2 and 3.1.3. You can upgrade to 2023.0.3 that came out last week and pick up THAT fix. However, the NEW token further down in your query is still breaking things, so I'm working on a patch for that.

@gregturn gregturn changed the title BadJpqlGrammarException with input parameter in date comparison in NEW as a part of a state field path expression in JPQL. Aug 28, 2023
gregturn added a commit that referenced this issue Aug 28, 2023
A multi-node token that has NEW as one of its elements should work just fine in a JPQL query.

See #3128
gregturn added a commit that referenced this issue Aug 28, 2023
A multi-node token that has NEW as one of its elements should work just fine in a JPQL query.

See #3128
gregturn added a commit that referenced this issue Aug 28, 2023
A multi-node token that has NEW as one of its elements should work just fine in a JPQL query.

See #3128
@gregturn
Copy link
Contributor

Merged to main. Backported to 3.1.x.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: query-parser Everything related to parsing JPQL or SQL status: feedback-provided Feedback has been provided type: regression A regression from a previous release
Projects
None yet
Development

No branches or pull requests

4 participants