简体   繁体   English

如何从HQL中转义单词

[英]How to escape reseved words from HQL

I have a table name Order and since it is a reserved word in Hibernate, it is not letting me to construct desired query. 我有一个表名Order,并且由于它是Hibernate中的保留字,因此不允许我构造所需的查询。 Is there any way by which I can escape table name in HQL? 有什么方法可以在HQL中转义表名?

I got across similar question asking for alias How to escape reserved words in Hibernate's HQL 我遇到类似的问题,要求提供别名如何在Hibernate的HQL中转义保留字

But this solution is not working for me. 但是此解决方案不适用于我。 Is there any other way by which we can do this? 还有其他方法可以做到这一点吗? I am using version 4.3 of hibernate. 我正在使用4.3版的休眠模式。

Have you mapped the table to an entity that is also called Order? 您是否已将表映射到也称为Order的实体? If so then I'd suggest renaming the entity as there as the Hibernate team appear to have rejected the request to add keyword escaping to HQL . 如果是这样,那么我建议重命名该实体,因为Hibernate团队似乎拒绝了向HQL添加关键字转义的请求 If the problem is actually with the generated SQL then you can add backticks to the table name to escape it according to the database dialect that is in use. 如果问题实际上出在生成的SQL上,则可以根据使用的数据库方言在表名中添加反引号,以对其进行转义。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM