Skip to content

spring data jpa findAll NULLSFIRST does not work #3658

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
Jon3012 opened this issue Nov 5, 2024 · 1 comment
Closed

spring data jpa findAll NULLSFIRST does not work #3658

Jon3012 opened this issue Nov 5, 2024 · 1 comment
Labels
status: duplicate A duplicate of another issue

Comments

@Jon3012
Copy link

Jon3012 commented Nov 5, 2024

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)

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Nov 5, 2024
@mp911de mp911de added status: duplicate A duplicate of another issue and removed status: waiting-for-triage An issue we've not yet triaged labels Nov 5, 2024
@mp911de
Copy link
Member

mp911de commented Nov 5, 2024

This is a duplicate of #1280. Null precedence is being supported with JPA 3.2+.

@mp911de mp911de closed this as not planned Won't fix, can't repro, duplicate, stale Nov 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: duplicate A duplicate of another issue
Projects
None yet
Development

No branches or pull requests

3 participants