0

このクエリを休止状態で実行すると、「org.hibernate.hql.ast.QuerySyntaxException: 予期しないトークン: ON near line 1, column 132」というエラーが発生します。休止状態に ON を使用する方法について、私のコードを手伝ってくれる人はいますか。

Session session  = (Session) em1.getDelegate();

org.hibernate.Query q=session.createQuery("UPDATE sc_ob_temp_audit set export_flag ='Y' WHERE audit_id IN(select a.audit_id FROM sc_ob_temp_audit a JOIN sc_ob_allocation b  ON a.sc_ob_profile_code = b.sc_ob_profile_code AND a.sc_orig_country= b.sc_orig_country LEFT OUTER JOIN sc_fac_group f ON   b.sc_orig_country = f.sc_orig_country AND b.sc_orig_sf_group_code = f.sc_fac_group_code LEFT OUTER JOIN (SELECT e.gp_cnt_cd,d.sc_prod_cont_code,d.sc_prod_group_code,d.sc_orig_country, e.gp_cd FROM sc_ob_prod_group d LEFT OUTER JOIN gbl_product e ON d.sc_prod_cont_code = e. gp_cnt_cd)de ON b.sc_orig_country = de.sc_orig_country AND b.sc_prod_cont_group_code=de.sc_prod_group_code WHERE a.sc_orig_country=:countryCd AND a.export_flag= 'N')");

q.setParameter("countryCd", country.trim());

q.executeUpdate();
4

3 に答える 3

1

SQL クエリを実行しようとしています。実行するには、代わりにSQLQueryオブジェクトを使用する必要があります。SQLQueryオブジェクトを取得するには、呼び出すだけですsession.createSqlQuery

一方、SQL ステートメントを書くだけなのに、なぜ Hibernate を使用しているのですか? sc_ob_temp_auditテーブルをマッピングしましたか?

于 2013-02-19T10:33:38.523 に答える
0

あなたのクエリを見た後、それはhqlのようには見えません。SQLクエリのように見えます。session.createQueryの代わりにsession.createSqlSqueryを使用してください。

于 2013-02-19T10:35:09.140 に答える
0

最初に HQL 構文について詳しく学ぶ必要があります。

以下も参照してください。

于 2013-02-19T10:44:46.537 に答える