-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Description
Summary
After upgrading to Spring Boot 4.x (Spring Data JPA 4.0.x) with EclipseLink 5.0.0-B13, some derived queries fail at runtime.
This issue appears to be separate from #4145 (IN clause list binding).
Background / Regression
We recently upgraded our project from Spring Boot 3.x to 4.x.
After the upgrade, several repository methods based on derived queries started failing at runtime unless rewritten using explicit @Query JPQL.
This suggests a regression or compatibility gap introduced by the combination of Spring Data JPA 4.x and EclipseLink 5 (Hermes JPQL parser).
Actual behavior
1. existsBy… derived queries fail with JPQL syntax error
EclipseLink 5 (Hermes) rejects JPQL generated for existsBy… queries due to an implicit alias in the select clause.
Example exception:
BadJpqlGrammarException: ... Syntax error parsing ... select o.id id ...
Generated JPQL (example):
SELECT o.id id FROM OfUser o
WHERE UPPER(o.email) = UPPER(?1)
AND o.id != ?2
AND o.isDelete != ?3Hermes appears to reject select o.id id (implicit alias without AS).
2. Parameter mismatch in findByIdAndIsDeleted
Some derived queries fail with a positional parameter binding error:
InvalidDataAccessApiUsageException:
Query argument 2 not found in the list of parameters provided during query execution
This seems to indicate that EclipseLink 5 under-reports positional parameters for certain derived queries.
Expected behavior
Derived queries should execute successfully on EclipseLink 5 without requiring explicit JPQL annotations.
Steps to reproduce (minimal)
Entity
@Entity
class SoftDeleteUser {
@Id
@GeneratedValue
Long id;
@Column(nullable = false)
String email;
@Column(nullable = false)
Integer isDeleted;
}Repository
interface SoftDeleteUserRepository
extends JpaRepository<SoftDeleteUser, Long> {
boolean existsByEmailIgnoreCaseAndIdNotAndIsDeletedNot(
String email, Long id, Integer isDeleted);
Optional<SoftDeleteUser> findByIdAndIsDeleted(
Long id, Integer isDeleted);
}Test scenario
- Persist two users with
isDeleted = 0 - Call
existsByEmailIgnoreCaseAndIdNotAndIsDeletedNot("USER@EXAMPLE.COM", otherId, 1) - Call
findByIdAndIsDeleted(activeId, 0)
Environment
- Spring Boot: 4.0.x
- Spring Data JPA: 4.0.2 (or current 4.x)
- EclipseLink: 5.0.0-B13
- JDK: 17
- Database: H2 (in-memory); also reproduced with other databases
Workaround
Annotating repository methods with explicit JPQL using @Query avoids these failures.
Additional notes / possible direction
- Hermes appears to reject JPQL with implicit select aliases (
select o.id id). - EclipseLink 5 also seems to under-report positional parameters in some derived queries, leading to
?2binding errors.
Links
- Related issue:
findByNameIn(List)fails withIllegalArgumentExceptionusing EclipseLink #4145 (different problem: IN-clause list binding) - Candidate fix with regression tests (fork):
Improve derived query compatibility with EclipseLink 5 hgwr/spring-data-jpa#1 - Fix EclipseLink 5 derived query compatibility #4168