Spring Pageable首先使用SQL Server为null

问题描述 投票:0回答:1

在我的应用程序中,我想添加到我的可分页对象中,我要为所选属性首先添加null订单。我在堆栈溢出时遵循了以下建议:How to use Pageable as get-query parameter in spring-data-rest?

喜欢此:

private Pageable customSort(Pageable pageable) {
    Sort sort = pageable.getSort();
    Order order = sort.iterator().next();
    List<Order> orders = new ArrayList<>();
    orders.add(new Order(order.getDirection(),order.getProperty()).nullsFirst());
    return PageRequest.of(pageable.getPageNumber(), pageable.getPageSize(), Sort.by(orders));
} 

但是我的问题是我们使用的SQL Server数据库不支持空值优先排序。 (如您在此处看到的:TSQL ORDER BY with nulls first or last (at bottom or top)

是否有解决方法,如何修改SQL Server数据库的可分页请求?

java sql-server spring spring-data-rest pageable
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.