I have a query that returns Person
objects that I’m using to fetch one page of results from the database:
def page(pageNumber:Int, pageSize:Int) : Seq[Person] = database.withSession {
val query = for(person <- People) yield person.mapped
val startIndex = (pageNumber - 1) * pageSize
query.list.slice(startIndex, startIndex + pageSize)
}
This works, but I want to know if I can do the paging in the database, in the same way as with the javax.persistence.Query
API's setFirstResult
and setMaxResults
methods, instead of using slice
on the resulting list.