Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
alexis-puska opened this issue Dec 30, 2020 · 1 comment
Closed
Labels
status: waiting-for-triage An issue we've not yet triaged

Comments

@alexis-puska
Copy link

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 ?

@mp911de mp911de added status: waiting-for-feedback We need additional information before we can continue status: waiting-for-triage An issue we've not yet triaged and removed status: waiting-for-feedback We need additional information before we can continue labels Dec 30, 2020
@schauder
Copy link
Contributor

schauder commented Jan 4, 2021

This is a duplicate of #1280 and caused by JPA not supporting specification of null precedence.

@schauder schauder closed this as completed Jan 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: waiting-for-triage An issue we've not yet triaged
Projects
None yet
Development

No branches or pull requests

3 participants