【发布时间】:2022-01-03 15:09:17
【问题描述】:
在通过 createNativeQuery() 查询时,使用混合了大写和小写的列名被转换为小写。下面是我的代码
Query query = entityManager.createNativeQuery("SELECT distinct a.admission_type_L1 FROM admission_type a");
List<String> result=query.getResultList();
我得到的错误如下
Hibernate: SELECT distinct a.admission_type_L1 FROM admission_type a
2021-11-25 15:28:21.646 WARN 2600 --- [ XNIO-1 task-1] o.h.engine.jdbc.spi.SqlExceptionHelper : SQL Error: 0, SQLState: 42703
2021-11-25 15:28:21.647 ERROR 2600 --- [ XNIO-1 task-1] o.h.engine.jdbc.spi.SqlExceptionHelper : ERROR: column a.admission_type_l1 does not exist
Hint: Perhaps you meant to reference the column "a.admission_type_L1".
它说 admission_type_l1 不存在,但我正在通过 admission_type_L1
如果我使用没有大写的列名,它可以正常工作
我的数据库是 postgreqsl
【问题讨论】:
标签: postgresql spring-boot entitymanager nativequery quoted-identifier