如何在hibernate中表达如下SQL:
SELECT *, ROW_NUMBER() OVER (ORDER BY SampledDate DESC) AS Row
FROM Sample
WHERE AssetId = @AssetId
如何在hibernate中表达如下SQL:
SELECT *, ROW_NUMBER() OVER (ORDER BY SampledDate DESC) AS Row
FROM Sample
WHERE AssetId = @AssetId
正如这里建议的那样,你没有。您创建一个ROW_NUMBER()
内部视图。
并且请注意,如果您有JOIN
s 可以“倍增”您的行,那么ROW_NUMBER()
除非您使用PARTITION BY