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
Post a Comment