Skip to content

spring data jpa findAll NULLSFIRST does not work  #3658

@Jon3012

Description

@Jon3012

Spring data jpa does not generate hql with NullsFirst .

I am using spring boot version 3.3.4 and trying to retrieve employee (for example) from postgres database using spring data jpa

Sort.Order order = new Sort.Order(Sort.Direction.ASC, "age", Sort.NullHandling.NULLS_FIRST)

employeeRepository.findAll(Sort.by(order));

while testing , generated query does not contain order by nulls first.

select id, name from employee order by age nulls first is missing in the generated query.

But if i add jpa.properties.hibernate.order_by.default_null_ordering = first in application.yml, then the generated query contains order by nulls first. and it works with nulls_last too. But i need to generate NullsFirst and Nulls last on the columns mentioned on Sort order like the example given .

How to fix this issue where jpa does not generate NullsFirst or NullsLast based on Sort order Null Handling (First and Last) example.. Sort.Order order = new Sort.Order(Sort.Direction.ASC, "age", Sort.NullHandling.NULLS_FIRST)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions