Row_number() over()

How to fetch the row_number using hibernate? I need exact same output for this query which is using postgres
select row_number() over(), name FROM person where id in (1,4);
row_number | name
1 | John
2 | Rita

You have to map it as a DTO. Check out this article for more details.