Reputation: 16837
Given the following page request let's say I wanted to Sort Descending by "created" but ascending by "name", how would I do that? the api doesn't seem to allow "direction" "field" pairs.
new PageRequest( 1, 15, Sort.Direction.DESC, "created", "name" )
using Spring Data JPA 1.6.5.
Upvotes: 3
Views: 5769
Reputation: 1
new PageRequest(1, 15, Sort
.by(Sort.Direction.DESC, "created")
.and(Sort.Direction.ASC, "name"))
Upvotes: 0
Reputation: 24403
Try this
new PageRequest(1, 15, new Sort(
new Order(Direction.DESC, "created"),
new Order(Direction.ASC, "name")
)
Upvotes: 2