jpa nulls last 不起作用

来源:互联网 发布:javascript长度函数 编辑:程序博客网 时间:2024/06/16 17:42

        List<Sort.Order> orders = new ArrayList<>();        Sort.Order orderRepostTime = new Sort.Order(Sort.Direction.ASC, "repostTime");        orders.add(orderRepostTime.nullsLast());        Sort sort = new Sort(orders);//repostTime ASC NULLS_LAST        Pageable pageable = new PageRequest(p - 1, size,sort);
上面的不起作用

有人说这是个bug

他就修复了https://github.com/spring-projects/spring-data-commons/pull/111 有兴趣的可以看看

Pageable pageable = new PageRequest(p - 1, size, JpaSort.unsafe("repostTime ASC NULLS LAST"));

上面这句就可以了


原创粉丝点击