spring data jpa multiple sorting
Asked Answered
B

1

4

I am using spring data jpa and JQGrid. I need response based on multiple sort parameters. I tried using sort parameter=column a,column b and sort order=asc but I am getting an exception

:No property column a,column b found in pojo.

It works if I would pass either of one columns as sort parameter. Code:

Pageable pageable = JPAUtility.constructPageSpecification(pageNumber, rowsPerPage, sortColName, sortOrder);

How can I pass multiple column names in sortColName parameter?

Barrelhouse answered 3/6, 2013 at 6:12 Comment(0)
L
9

In Spring Data you just need to add Sort parameter into findBy* method. Sort object has got a couple constructors, e.g.

Sort(Direction direction, String... properties)

which is probably exactly what you need. If you need to specify different directions for various properties then you can use

Sort(Order... orders)

where Order has property and direction: Order(Direction direction, String property)

Lacy answered 3/1, 2014 at 22:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.