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 ]

Resources はテーブルであり、hibernate.cfg.xml にマッピング設定があります

  1. 「KEY」は、変更できない列の1つの名前であると考えていました。キーワードをエスケープするにはどうすればよいですか?

  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 に答える