-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BadJpqlGrammarException when using column names coinciding with functions in projection #2994
Comments
@gregturn Can we reuse |
We were actually wondering whether it would make sense to reuse Hibernate's HQL parser as both implementations, Hibernate's and ours, use ANTLR. Skimming through the linked ticket I get the impression that using Hibernate's HQL parser is the way to go. |
Merged to NOTE: @quaff I am investigating hooking in our processing through HQL's |
Exact same error occurs if the entity has an attribute labeled "value" |
@gregturn my mistake. Duly noted for next time. Thank you for having handled this case. |
Summary
I am unable to use columns with names identical to function names in projections.
Context
Given I have an entity with a column called
sign
:With a pojo defined that I want to project into:
Now, defining and running the following jpql query
leads to an exception
I would expect it to resolve
t.sign
to be thesign
property of theTestEntity
. What I think is what really happens is thatsign
is resolved to be thesign()
function (i.e.sign(-10) = -1
).A similar exception occurs, when the column gets renamed to other popular function names such as
log
orexp
. Renaming the column tosigning
leads to the query working as expected.Environment
Regression
This behavior is new in our project after upgrading to spring 3. Our current production code contains the same setup as described above and behaves as expected (no error). We are currently running 2.7.11 there:
nota bene
I have previously raised this issue with the hibernate ORM project (link) . Their initial analysis pointed to this being a spring data jpa specific issue which is why I am also adding it here.
The text was updated successfully, but these errors were encountered: