如何将此SQL查询编写为Hibernate查询?
SELECT u.id, u.orderId, p.productName, u.key2, i.forsor_id
FROM `ub_orders` u JOIN
productInfo p
ON p.productId=u.productId JOIN
ir i
ON u.key2=i.id
WHERE p.productName LIKE '%OSS HOSTING FEE%' AND
u.createdDate > 2014-02-1 AND
forsor_id IS NULL
ORDER BY u.key2;
答案 0 :(得分:0)
我很容易看到两个问题。第一个是使用反引号,第二个是在日期常量周围需要单引号:
SELECT u.id, u.orderId, p.productName, u.key2, i.forced_matrix_sponsor_id
FROM ubercart_reseller_orders u join
productInfo p
on p.productId=u.productId join
ir i
on u.key2=i.id
where p.productName like '%OSS HOSTING FEE%' and
u.createdDate > '2014-02-1' and
----------------------^
forced_matrix_sponsor_id is null
order by u.key2;