spring data jpa多重排序

abi*_*bii 3 sorting jqgrid spring-data-jpa

我正在使用spring数据jpa和JQGrid.我需要基于多个排序参数的响应.我尝试使用sort参数=列a,列b和排序顺序= asc,但我得到一个例外

:没有属性列a,列po在pojo中找到.

如果我将一列作为排序参数传递,它可以工作.码:

Pageable pageable = JPAUtility.constructPageSpecification(pageNumber, rowsPerPage, sortColName, sortOrder);
Run Code Online (Sandbox Code Playgroud)

如何在sortColName参数中传递多个列名?

Jak*_*ski 8

在Spring Data中,您只需要将Sort参数添加到findBy*方法中.Sort对象有一些构造函数,例如

Sort(Direction direction, String... properties)
Run Code Online (Sandbox Code Playgroud)

这可能正是你所需要的.如果您需要为各种属性指定不同的方向,那么您可以使用

Sort(Order... orders)
Run Code Online (Sandbox Code Playgroud)

订单有财产和方向: Order(Direction direction, String property)