Closed filpano closed 2 months ago
Thank you for getting in touch. The given Stacktrace indicates that this is a problem within PG. A reproducer would certainly help.
Please make sure to not only run the query via a spring-data repository, but also using plain EntityManager#createNativeQuery
. Thank you!
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.
Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.
I am using Spring Boot
3.2.4
with Spring Data JPA. I have the followingJpaRepository
with a native query against PostgreSQL 15:When this is run, I get the following exception:
At first I thought that this might be because of the naming of my
hour
column: according to the PostgreSQL Appendix, it is not a reserved keyword and only requires aliasing (as I have done here).If I run this query in e.g.
psql
, it works as expected, hence I believe this to be either a bug in in Spring Data JPA's handling of native queries or perhaps even a problem with Hibernate itself. I haven't debugged this exhaustively.The current workaround is to refer to the grouping column by index, i.e.:
which works as expected.
I can try to get a minimal reproducible example up and running this weekend. I imagine it won't be very hard to reproduce: use a native query that contains function with an alias for a column in a
GROUP BY
and see what happens.Full stacktrace of the relevant JPA code: