I'm in the process of upgrading a Spring Boot 2.7.x application to Spring Boot 3.2.
One of my Spring Data repository classes PriorityDao extends JpaRepository contains this query method:
@Query("""
SELECT t FROM Priority t
WHERE t.accountId IN :accountIds
AND t.priorityDate BETWEEN :start AND :end
ORDER BY t.priorityDate, t.accountId
""")
List findByAccountIdsAndDateRange(
@Param("accountIds") List accountIds,
@Param("start") LocalDate start,
@Param("end") LocalDate end
);
The application was previously using EclipseLink 2.7.9 as JPA implementation.
Now with the Spring Boot upgrade, I've migrated to EclipseLink 4.0.2, and this JPQL query stopped working. Now I get this error whenever this method is called:
java.lang.IllegalArgumentException: org.springframework.data.jpa.repository.query.BadJpqlGrammarException: Line 3:49 no viable alternative at input 't.priorityDateBETWEEN:startAND:end'; Bad JPQL grammar [ SELECT t FROM Priority t
WHERE t.accountId IN :accountIds
AND t.priorityDate BETWEEN :start AND :end
ORDER BY t.priorityDate, t.accountId
]
at org.springframework.data.jpa.repository.query.JpaQueryParserSupport.renderSortedQuery(JpaQueryParserSupport.java:56) ~[spring-data-jpa-3.2.2.jar:3.2.2]
at org.springframework.data.jpa.repository.query.JpaQueryEnhancer.applySorting(JpaQueryEnhancer.java:103) ~[spring-data-jpa-3.2.2.jar:3.2.2]
Am I doing something wrong or did EclipseLink stop supporting the BETWEEN operator?