java - JPA get the previous and next record in select -


i have jpql query retrieves sorted list of entities database. have id of 1 of these entities. how can previous , next record record known id in select?

select distinct n news n      inner join n.author      inner join n.tags t      a.id = :authorid , t.id in :tagsid      order size(n.comments) desc 

news has 1 author, many tags , comments. select news given author , tags , order them count of comments them.

while using jdbc i've solved such problems using rownum.

can position(rownum) of record in result using jpa? if knew record's position define first result position - 1, , max results 3 given query. how previous, current , next news.

are there other solutions, except iterating through list of news?


Comments

Popular posts from this blog

javascript - Karma not able to start PhantomJS on Windows - Error: spawn UNKNOWN -

Nuget pack csproj using nuspec -

c# - Display ASPX Popup control in RowDeleteing Event (ASPX Gridview) -