postgresql - 在使用 camelCase 定义的数据库中时,PostgreSQL“列不存在”
问题描述
我对 Postgres 有一个有趣的情况(类似于PostgreSQL“列不存在”,但它确实存在)。即列或表名包含大写字母。在上面的给定链接中,它是关于表名的。
就我而言,在数据库中,我在 camelCase 中定义了一个列“projectId”(数据库中的 SQL 看起来像“..“projectId”整数 NOT NULL,..')。在后端我使用 Java 和 Hibernate。当我尝试使用命名查询(例如“SELECT e FROM ProjectTa e”)获取表的所有条目时,我收到错误消息:
org.hibernate.exception.SQLGrammarException: could not extract ResultSet
Caused by: org.postgresql.util.PSQLException: ERROR: column projectta0_.projectid does not exist
Hinweis: Perhaps you meant to reference the column "projectta0_.projectId".
Position: 138
SQL 日志:
select projectta0_.id as id1_1_, projectta0_.budget as budget2_1_, projectta0_.completion as completi3_1_, projectta0_.name as name4_1_, projectta0_.projectId as projectI5_1_, p
rojectta0_.status as status6_1_, projectta0_.users as users7_1_ from project_ta projectta0_
'FROM "Tablename" ' 将解决表名问题。如果我只想要表的所有条目,我必须如何调整我的命名查询。(我不想在我的实体中更改列名或使用 @Column 的名称)
解决方案
推荐阅读
- python - 在 Keras 中一次上传一部分数据集
- ms-access - 生成包含期初和期末余额的 MS Access 报告
- android - 如何在重新启动后重新启动服务而不通过前台服务显示任何通知
- deepsecurity - 我可以使用 DeepSecurity API(带有 java sdk)检查扫描和检测到的病毒列表吗?
- javascript - 加入服务器时将新成员静音
- javascript - React js - 单击浏览器后退按钮时如何恢复过滤器?
- c - 如果我在 scanf 中传递变量值而不是变量引用会发生什么?
- python - 如何修复 TypeError:ord() 期望一个字符,但找到长度为 403 的字符串?
- internationalization - 如何使用 Sphinx 翻译代码块中的注释
- javascript - 添加更多值