小编dot*_*otS的帖子

Null Last 不适用于 spring 数据 jpa

NULL LAST不适用于弹簧数据 JPA。

这是我正在使用的代码。

服务层代码:

Sort sort = new Sort(new Sort.Order(Sort.Direction.DESC, "user_name").nullsLast());
Pageable pageable = PageRequest.of(0, 10, sort);
userRepository.findAllUsers(pageable)
Run Code Online (Sandbox Code Playgroud)

回购层代码:

@Query(value = "Select * from users", nativeQuery = true)
Page<User> findAllUsers(Pageable pageable);
Run Code Online (Sandbox Code Playgroud)

预期/实际输出:

Expected: Null values should come at the last
Actual: Null values are coming at the top
Run Code Online (Sandbox Code Playgroud)

使用

Spring Boot version: **2.1.6.RELEASE**
Database Postgres version: **42.2.5**
Run Code Online (Sandbox Code Playgroud)

有哪位朋友可以帮帮我吗?

spring pagination spring-data-jpa spring-boot

3
推荐指数
1
解决办法
2513
查看次数

标签 统计

pagination ×1

spring ×1

spring-boot ×1

spring-data-jpa ×1