Skip to content

Spring data specification pageable NULLS_[FIRST/LAST] not working.  #2128

Closed
@alexis-puska

Description

@alexis-puska

Hi all,
I have create a specification for querying my database, I would like to set the precedence of null ordering, I create a pageable with custom sort :

Pageable customPageable = pageable;

    for (Order sort : pageable.getSort()) {
        if (sort.getProperty().equals("column")) {
            List<Sort.Order> orderList = new ArrayList<>();
            if (sort.isAscending()) {
                orderList.add(new Sort.Order(Sort.Direction.ASC,
                        "column", NullHandling.NULLS_FIRST));
            } else {
                orderList.add(new Sort.Order(Sort.Direction.DESC,
                        "column", NullHandling.NULLS_LAST));
            }
            customPageable = PageRequest.of(pageable.getPageNumber(), pageable.getPageSize(), Sort.by(orderList));
        }
    }

repository.findAll(new Specification(), customPageable);

And when the request is execute on postgres database, only ASC or DESC is readable inside the log file.

i do it wrong, this is a missing functionnality or a bug ?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions