2014-12-25 41 views
0

一個能寫HQL以及使用標準或谷歌API的generalDaoHibernate查詢:順序按時間差

SELECT id, 
    CASE WHEN from_time > current_timestamp THEN (from_time - current_timestamp) 
     ELSE (current_timestamp - from_time) 
       END as a 
FROM meetings order by a; 
+0

查看以下鏈接:https://docs.jboss.org/hibernate/orm/3.5/reference/en/html/queryhql.html#queryhql-expressions。這可能是你正在尋找的。 – Ambrish

回答

0
  1. 您可以使用CASE in your HQL queries Hibernate的查詢語法。

  2. 而不是current_timestamp你應該使用CURRENT_TIMESTAMP()函數,這也是HQL支持的。