Skip to content

AOT generated repositories are not handling NULL parameters #4304

Description

@LoganWlv

In our Spring Boot project, we do use spring.aot.repositories.enabled.
Let's consider this repository:

public interface ThingRepository extends JpaRepository<Thing, UUID> {
    @Query("SELECT t FROM Thing t WHERE t.groupId = :groupId")
    List<Thing> findByGroupId(UUID groupId);
}

where groupId is nullable.

The AOT-generated method will be:

public List<Thing> findByGroupId(UUID groupId) {
    String var2 = "SELECT t FROM Thing t WHERE t.groupId = :groupId";
    Query var3 = this.entityManager.createQuery(var2);
    var3.setParameter("groupId", groupId);
    return var3.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.

Spring Boot: 4.1.0
MacOs: 26.5.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions