When upgrading to org.springframework.data:spring-data-jpa:jar:3.2.11 (via spring-boot 3.2.11) we experience the following error. Upgrading to spring-boot 3.3.5 raises the same error, 3.3.4 seems to be fine.
Caused by: org.springframework.data.repository.query.QueryCreationException: Could not create query for public abstract void de....repositories.AuditEntryRepository.deleteBefore(java.time.LocalDateTime); Reason: Cannot invoke "org.antlr.v4.runtime.ParserRuleContext.getParent()" because "ctx" is null
at org.springframework.data.repository.query.QueryCreationException.create(QueryCreationException.java:101)
at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.lookupQuery(QueryExecutorMethodInterceptor.java:119)
at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.mapMethodsToQuery(QueryExecutorMethodInterceptor.java:103)
at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.lambda$new$0(QueryExecutorMethodInterceptor.java:92)
at java.base/java.util.Optional.map(Optional.java:260)
at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.<init>(QueryExecutorMethodInterceptor.java:92)
at org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:357)
at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.lambda$afterPropertiesSet$5(RepositoryFactoryBeanSupport.java:290)
at org.springframework.data.util.Lazy.getNullable(Lazy.java:135)
at org.springframework.data.util.Lazy.get(Lazy.java:113)
at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.afterPropertiesSet(RepositoryFactoryBeanSupport.java:296)
at org.springframework.data.jpa.repository.support.JpaRepositoryFactoryBean.afterPropertiesSet(JpaRepositoryFactoryBean.java:132)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1853)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1802)
... 52 more
Caused by: java.lang.NullPointerException: Cannot invoke "org.antlr.v4.runtime.ParserRuleContext.getParent()" because "ctx" is null
at org.springframework.data.jpa.repository.query.HqlQueryTransformer.isSubquery(HqlQueryTransformer.java:105)
at org.springframework.data.jpa.repository.query.HqlQueryTransformer.isSubquery(HqlQueryTransformer.java:105)
at org.springframework.data.jpa.repository.query.HqlQueryTransformer.isSubquery(HqlQueryTransformer.java:105)
at org.springframework.data.jpa.repository.query.HqlQueryTransformer.isSubquery(HqlQueryTransformer.java:105)
at org.springframework.data.jpa.repository.query.HqlQueryTransformer.isSubquery(HqlQueryTransformer.java:105)
at org.springframework.data.jpa.repository.query.HqlQueryTransformer.isSubquery(HqlQueryTransformer.java:105)
at org.springframework.data.jpa.repository.query.HqlQueryTransformer.visitVariable(HqlQueryTransformer.java:362)
at org.springframework.data.jpa.repository.query.HqlQueryRenderer.visitVariable(HqlQueryRenderer.java:1)
at org.springframework.data.jpa.repository.query.HqlParser$VariableContext.accept(HqlParser.java:10200)
at org.antlr.v4.runtime.tree.AbstractParseTreeVisitor.visit(AbstractParseTreeVisitor.java:18)
at org.springframework.data.jpa.repository.query.HqlQueryRenderer.visitTargetEntity(HqlQueryRenderer.java:481)
at org.springframework.data.jpa.repository.query.HqlQueryRenderer.visitTargetEntity(HqlQueryRenderer.java:1)
at org.springframework.data.jpa.repository.query.HqlParser$TargetEntityContext.accept(HqlParser.java:2018)
at org.antlr.v4.runtime.tree.AbstractParseTreeVisitor.visit(AbstractParseTreeVisitor.java:18)
at org.springframework.data.jpa.repository.query.HqlQueryRenderer.visitDeleteStatement(HqlQueryRenderer.java:526)
at org.springframework.data.jpa.repository.query.HqlQueryRenderer.visitDeleteStatement(HqlQueryRenderer.java:1)
at org.springframework.data.jpa.repository.query.HqlParser$DeleteStatementContext.accept(HqlParser.java:2198)
at org.antlr.v4.runtime.tree.AbstractParseTreeVisitor.visit(AbstractParseTreeVisitor.java:18)
at org.springframework.data.jpa.repository.query.HqlQueryRenderer.visitQl_statement(HqlQueryRenderer.java:46)
at org.springframework.data.jpa.repository.query.HqlQueryRenderer.visitQl_statement(HqlQueryRenderer.java:1)
at org.springframework.data.jpa.repository.query.HqlParser$Ql_statementContext.accept(HqlParser.java:303)
at org.antlr.v4.runtime.tree.AbstractParseTreeVisitor.visit(AbstractParseTreeVisitor.java:18)
at org.springframework.data.jpa.repository.query.HqlQueryRenderer.visitStart(HqlQueryRenderer.java:35)
at org.springframework.data.jpa.repository.query.HqlQueryRenderer.visitStart(HqlQueryRenderer.java:1)
at org.springframework.data.jpa.repository.query.HqlParser$StartContext.accept(HqlParser.java:247)
at org.antlr.v4.runtime.tree.AbstractParseTreeVisitor.visit(AbstractParseTreeVisitor.java:18)
at org.springframework.data.jpa.repository.query.HqlQueryParser.doFindAlias(HqlQueryParser.java:101)
at org.springframework.data.jpa.repository.query.JpaQueryParserSupport.findAlias(JpaQueryParserSupport.java:96)
at org.springframework.data.jpa.repository.query.JpaQueryEnhancer.detectAlias(JpaQueryEnhancer.java:124)
at org.springframework.data.jpa.repository.query.StringQuery.<init>(StringQuery.java:90)
at org.springframework.data.jpa.repository.query.ExpressionBasedStringQuery.<init>(ExpressionBasedStringQuery.java:64)
at org.springframework.data.jpa.repository.query.AbstractStringBasedJpaQuery.<init>(AbstractStringBasedJpaQuery.java:85)
at org.springframework.data.jpa.repository.query.SimpleJpaQuery.<init>(SimpleJpaQuery.java:68)
at org.springframework.data.jpa.repository.query.JpaQueryFactory.fromMethodWithQueryString(JpaQueryFactory.java:60)
at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$DeclaredQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:170)
at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$CreateIfNotFoundQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:252)
at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$AbstractQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:95)
at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.lookupQuery(QueryExecutorMethodInterceptor.java:115)
The offending query is
@Modifying
@Query("delete from #{#entityName} as a where a.created < :before")
void deleteBefore(@Param("before") LocalDateTime before);
Downgrading to org.springframework.data:spring-data-jpa:jar:3.2.10 (using <spring-data-bom.version>2023.1.10</spring-data-bom.version> fixes the problem.
Hibernate version is org.hibernate.orm:hibernate-core:jar:6.4.10.Final, antlr is org.antlr:antlr4-runtime:jar:4.13.0
When upgrading to
org.springframework.data:spring-data-jpa:jar:3.2.11
(via spring-boot3.2.11
) we experience the following error. Upgrading to spring-boot3.3.5
raises the same error,3.3.4
seems to be fine.The offending query is
Downgrading to
org.springframework.data:spring-data-jpa:jar:3.2.10
(using<spring-data-bom.version>2023.1.10</spring-data-bom.version>
fixes the problem.Hibernate version is
org.hibernate.orm:hibernate-core:jar:6.4.10.Final
, antlr isorg.antlr:antlr4-runtime:jar:4.13.0