我想从表中获取最新记录。我的sql如下。
选择*来自(选择*来自TABLE_1 WHERE paid = 1个订单,按PAYMENTDATE DESC)在哪里ROWNUM = 1
我尝试使用HQL和映射pojo类来完成它。它给出了错误。我的HQL如下。
SELECT pay FROM(SELECT pay FROM com.Table1 as payment in WHERE payment.paid = 1 ORDER BY payment.paymentDate DESC)as pay where pay.ROWNUM = 1
错误是,
net.sf.hibernate.QueryException:in expected:SELECT [SELECT pay FROM (选择从com.TABLE1付款作为付款WHERE payment.paid = 1 ORDER BY payment.paymentDate DESC)as pay.ROWNUM = 1]
没有子查询的普通查询正在运行。
例如:
从com.Table1中选择付款作为付款WHERE payment.paid = 1
请帮助解决这个问题。