0

该设置由 Hibernate 3 组成。我正在尝试按原样执行原始查询。该设置适用于其他简单查询、数据库插入和更新。

有问题的查询是:

   org.hibernate.hql.ast.QuerySyntaxException: unexpected token: ( near line 1, column 29 [
          SELECT keyMain, value FROM (select distinct K.[key] as keyMain,
            ( SELECT value FROM com.trans.dto.Resources as L WHERE L.[key] = K.[key] 
              and L.lang_code = 'A11' ) as value from com.trans.dto.Resources as  K ) 
              as test order by keyMain ]

资源是表并在 hibernate.cfg.xml 中有映射设置

  1. 我在想“KEY”是无法更改的列之一的名称。我如何逃避关键词?

  2. 如果不是 1,那么就是子查询中的多选。

请指教。任何建议都有很大帮助。

4

1 回答 1

0

这里

You can force Hibernate to quote an identifier in the generated SQL
by enclosing the table or column name in backticks in the mapping document. 
Hibernate will use the correct quotation style for the SQL Dialect. 
This is usually double quotes, but the SQL Server uses brackets and MySQL uses backticks.

因此,请尝试使用双引号或方括号 ('[key]') 转义您的字段。

于 2013-06-06T21:57:18.307 回答