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

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -