2

How to express the following SQL in hibernate:

SELECT *, ROW_NUMBER() OVER (ORDER BY SampledDate DESC) AS Row
FROM Sample
WHERE AssetId = @AssetId
xanatos
  • 109,618
  • 12
  • 197
  • 280
user1096760
  • 87
  • 2
  • 8

1 Answers1

0

As suggested here you don't. You create a view with the ROW_NUMBER() inside.

And be aware that if you have JOINs that "multiply" your rows, then your ROW_NUMBER() will be nearly useless unless you use the PARTITION BY

Community
  • 1
  • 1
xanatos
  • 109,618
  • 12
  • 197
  • 280