2017-07-17 4 views
-1
String query ="From transaction JOIN outlet transaction.outlet_ref_id = outlet.outletid WHERE(transaction.added_date_time between'"+sdate+"' and '"+edate+"') and (outlet.merchant ="+merchantId+")"; 

これは私がデータベースからデータを取得するために使用しているクエリです。これは、Navicatでこのクエリを使用しているときに機能し、データを提供します。しかし、私はそれを次のエラーを与えるハイバネートクエリとして使用しています。 from Company as comp inner join comp.employees as emp構文Hibernate SQLで2つのテーブルを結合してデータベースからデータを取得するときのエラー

enter image description here

答えて

1

は、クエリのリンクを記述する必要があります。 Company as compは、entityName as referenceNameを意味します。

From Transaction t JOIN Outlet o t.outlet_ref_id = o.outletid WHERE(t.added_date_time between'"+sdate+"' and '"+edate+"') and (o.merchant ="+merchantId+")

よりご参照のためTransaction

にエンティティ名を使用します。

http://www.concretepage.com/hibernate/hibernate-hql-associations-and-inner-join-left-outer-join-right-outer-join-cross-join-example

https://docs.jboss.org/hibernate/orm/3.3/reference/en/html/queryhql.html

http://levelup.lishman.com/hibernate/hql/joins.php

+0

Iヘクタールこれを試しました...同じエラーが発生しています....? – Toshan

+0

あなたの 'transaction'と' outlet'エンティティコードを共有し、あなたが実行している場所でjavaコードを共有してください – Sharma

関連する問題