You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
AOT generated repositories are not handling NULL parameters #4304
In our Spring Boot project, we do use spring.aot.repositories.enabled.
Let's consider this repository:
publicinterfaceThingRepositoryextendsJpaRepository<Thing, UUID> {
@Query("SELECT t FROM Thing t WHERE t.groupId = :groupId")
List<Thing> findByGroupId(UUIDgroupId);
}
where groupId is nullable.
The AOT-generated method will be:
publicList<Thing> findByGroupId(UUIDgroupId) {
Stringvar2 = "SELECT t FROM Thing t WHERE t.groupId = :groupId";
Queryvar3 = this.entityManager.createQuery(var2);
var3.setParameter("groupId", groupId);
returnvar3.getResultList();
}
It works until groupId is null; the final query does not use IS NULL.
I didn't try to annotate the field @Nullable as I don't expect such behavior to be driven by those annotations.
Thanks for the report. This is a known gap. The primary idea of AOT repositories is to have exactly the query rendered as AOT variant that is going to be ran against the database. Considering nullability would require string concatenation or JPQL query parsing resulting again in code that is hard to read and hard to debug. This needs further investigation to find a better approach.
Thanks for the report. This is a known gap. The primary idea of AOT repositories is to have exactly the query rendered as AOT variant that is going to be ran against the database. Considering nullability would require string concatenation or JPQL query parsing resulting again in code that is hard to read and hard to debug. This needs further investigation to find a better approach.
Agree that you would need JPQL parsing. I wonder if it is worth adding a point in the limitations section of here then 🤔
Activity
LoganWlv commentedon Jul 28, 2026
Happy to do the PR once this is confirmed
mp911de commentedon Aug 3, 2026
Thanks for the report. This is a known gap. The primary idea of AOT repositories is to have exactly the query rendered as AOT variant that is going to be ran against the database. Considering nullability would require string concatenation or JPQL query parsing resulting again in code that is hard to read and hard to debug. This needs further investigation to find a better approach.
LoganWlv commentedon Aug 3, 2026
Agree that you would need JPQL parsing. I wonder if it is worth adding a point in the limitations section of here then 🤔