2012-09-26 68 views
1

如何在HQL中編寫此查詢?如何在HQL中編寫內聯查詢

SELECT CASE WHEN data1 > data2 THEN data1 ELSE data2 END AS data, STAMP FROM 
(SELECT STAMP, max(mc.data1) as data1, max(mc.data2) as data2 FROM 
transaction_history mc LEFT JOIN orderdetails gc on mc.id = gc.id where 
gc.order_name in ('xxx','yyy') AND time >= 135689 AND time <= 137692) AS TBL 

當我試圖複製上述查詢的HQL我:

org.hibernate.hql.ast.QuerySyntaxException exception saying unexpected token "(". 

回答

0

嘗試在實體使用分離的標準和使用corelated子查詢主要標準加入,然後使用公式中的字段爲了達成這個。 Hibernate沒有像你這樣做的內聯查詢支持。