With 3.1.0, repository initialization fails with
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:100) ~[spring-data-jpa-3.1.0.jar:3.1.0]
when declaring the following named query:
insert into MyEntity (id, col)
select max(id), col
from MyEntityStaging
group by col
Entities:
@Entity
@NamedQuery(name = "MyEntity.copyFromStaging", query = """
insert into MyEntity (id, col)
select max(id), col
from MyEntityStaging
group by col""")
class MyEntity {
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE)
private Long id;
private String col;
}
@Entity
class MyEntityStaging {
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE)
private Long id;
private String col;
}
Repository:
interface MyEntityRepository extends JpaRepository<MyEntity, Long> {
@Modifying
@Transactional
void copyFromStaging();
}
Reproducer:
demo.zip
Extract and run ./mvnw spring-boot:run to observe the exception.
In the pom.xml, change the spring-data-jpa.version from 3.1.0 to 3.0.6 and run again, now it works.
With 3.1.0, repository initialization fails with
when declaring the following named query:
Entities:
Repository:
Reproducer:
demo.zip
Extract and run
./mvnw spring-boot:runto observe the exception.In the pom.xml, change the
spring-data-jpa.versionfrom3.1.0to3.0.6and run again, now it works.