Skip to content

Positional parameter skipped when query collapses to id IS NULL #4171

@hgwr

Description

@hgwr

Hi team,

I’m seeing a positional binding failure with EclipseLink 5 when a derived query collapses to id IS NULL and only the second positional parameter remains. In that case EclipseLink reports only position 2, but Spring Data checks query.getParameters().size() and skips binding position 2 because the size is 1. That ends up with:

Query argument 2 not found in the list of parameters provided during query execution.

Minimal repro (abstracted):

@Entity
class SampleEntity {
  @Id Long id;
  int isDeleted;
}

interface SampleRepository extends JpaRepository<SampleEntity, Long> {
  Optional<SampleEntity> findByIdAndIsDeleted(Long id, Integer isDeleted);
}

// With EclipseLink 5
repository.findByIdAndIsDeleted(null, 0);

The derived JPQL becomes:
SELECT e FROM SampleEntity e WHERE e.id IS NULL AND e.isDeleted = ?2

I proposed a fix in PR #4170 that binds positional parameters based on the reported positions (and only falls back to the size check when no positional metadata is available):
#4170

This issue is related to #4167, but I’m trying to keep the report focused on the positional under‑reporting case. Please let me know if you’d prefer a different repro or additional detail.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions