通过在 Hibernate 中连接两个表从数据库中检索数据时出现语法错误 Sql
Syntax Error when retrieving data from database by joining two tables in Hibernate Sql
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 中使用此查询并提供数据时,这是有效的。但是我将其用作休眠查询,它会出现以下错误。
您需要编写查询 Link : from Company as comp inner join comp.employees as emp
。
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
上使用实体名称
更多参考:
https://docs.jboss.org/hibernate/orm/3.3/reference/en/html/queryhql.html
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 中使用此查询并提供数据时,这是有效的。但是我将其用作休眠查询,它会出现以下错误。
您需要编写查询 Link : from Company as comp inner join comp.employees as emp
。
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
更多参考:
https://docs.jboss.org/hibernate/orm/3.3/reference/en/html/queryhql.html