简体   繁体   中英

SQL query into Hibernate query

How do I write this SQL query as a Hibernate query?

 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;

I readily see two problems. The first is the use of backticks and the second is the need for single quotes around the date constant:

 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;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM