Improve error message when required field is missing in query [DATAJDBC-613]
See original GitHub issuebenzen opened DATAJDBC-613 and commented
In a repository I have the following method
@Query("""
select start, "end", timesheet.state from timesheet
join time_entry on time_entry.timesheet = timesheet.id
where
time_entry.project_id in (:projectIds);
“”")}}
public List<Timesheet> findByTimeEntryProjectIdIn(final List<Long> projectIds);
Here is the top part of the exception
An empty SqlIdentifier can't be used in to create column names
java.lang.UnsupportedOperationException: An empty SqlIdentifier can't be used in to create column names at org.springframework.data.relational.core.sql.SqlIdentifier$1.getReference(SqlIdentifier.java:68) at org.springframework.data.jdbc.core.convert.SqlGenerator.renderReference(SqlGenerator.java:705) at org.springframework.data.jdbc.core.convert.SqlGenerator.getBindMarker(SqlGenerator.java:152) at org.springframework.data.jdbc.core.convert.SqlGenerator.buildConditionForBackReference(SqlGenerator.java:234) at org.springframework.data.jdbc.core.convert.SqlGenerator.getFindAllByProperty(SqlGenerator.java:219) at org.springframework.data.jdbc.core.convert.DefaultDataAccessStrategy.findAllByPath(DefaultDataAccessStrategy.java:348)
It's unclear to me what is happening`` here.
I assume that it's related to the fact that one of my column use a reserved keyword.
Could not find anything related to this issue
Attachments:
- demo.zip (97.11 kB)
Issue Analytics
- State:
- Created 3 years ago
- Comments:14 (2 by maintainers)
@spring-projects-issues I would like to improve the error messaging here. From the last comment, I understand the issue was that a new “id” column was added to the “timesheet” DB table, and the code was using “GROUP BY” aggregation queries where the new column was missing.
My suggestion would be to change the error message from the
SqlIdentifier
from"An empty SqlIdentifier can't be used in to create column names"
to"An empty SqlIdentifier can't be used in to create column names. Ensure that all selected fields are present in the aggregation clause"
Can I raise a PR with this?
Sure, go ahead.