jpa - How to get the entry index in a query with ORDER BY -


i need figure out way index of every entry in query result, let me show example:

suppose have 3 entries in person table.

  • willie
  • mike
  • alan

and want query table return it's entries, , want know index in returned, jpql

a pseudo code this:

select [index], p.name person p order p.name 

what should replace [index] result this:

1 - alan 2 - mike 3 - willie 

is there way using jpql?

you use database function , call using func() (eclipselink) or function() (jpa 2.1) jpql. eclipselink supports sql() embed sql want inside jpql. or use native query, or add index in java code, since don't need select database.


Comments

Popular posts from this blog

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

Android Gson.fromJson error -