Skip to content

Error when using reserved words in JPQL query for entity field names and packages #3832

Closed
@DmitryBelousov1992

Description

@DmitryBelousov1992

The following errors were found during migration to springboot 3.x.:

BadJpqlGrammarException: Line 1:43 no viable alternative at input 'ie.object'; Bad JPQL grammar [select ie from ItemExample ie left join ie.object io where io.externalId = :externalId]
for
@query("select ie from ItemExample ie left join ie.object io where io.externalId = :externalId")
Page findPageByExternalId(@param("externalId") String externalId, Pageable pageable);
BadJpqlGrammarException: Line 1:63 no viable alternative at input 'ie.status=com.app.domain.object'; Bad JPQL grammar [select ie from ItemExample ie where ie.status = com.app.domain.object.Status.UP]
for
@query("select ie from ItemExample ie where ie.status = com.app.domain.object.Status.UP")
Page findByStatusUp(Pageable pageable);

I am attaching an example springboot 3.x application with detailed comments and examples of errors and workarounds found in the file com.app.repo.ItemExampleRepository.
https://github.com/DmitryBelousov1992/SpringReservedWordsExampleErrors.git

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions