Skip to content
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

Allow specification for null handling in order-by expressions (JPQL and Criteria API) #76

Closed
lukasj opened this issue Mar 17, 2014 · 10 comments · Fixed by #440
Closed

Comments

@lukasj
Copy link
Contributor

lukasj commented Mar 17, 2014

§4.9 of the specification explictly states:

SQL rules for the ordering of null values apply: that is, all null values must appear before all non-null values in the ordering or all null values must appear after all non-null values in the ordering, but it is not specified which.

However, pretty much all of the important JPA providers support a nulls first/nulls last clause. So while it is already possible to define the strategy, it would be cool if one could reliably use it on top of JPA.

@lukasj
Copy link
Contributor Author

lukasj commented Mar 17, 2014

@glassfishrobot Commented
Reported by oliver.gierke

@lukasj
Copy link
Contributor Author

lukasj commented Aug 13, 2014

@glassfishrobot Commented
c.beikov said:
Also not that this is important for database exchangeability. If I didn't specify nulls first or nulls last every query that uses the order by is non-portable between databases since databases have different defaults.

@lukasj
Copy link
Contributor Author

lukasj commented May 5, 2017

@glassfishrobot Commented
This issue was imported from java.net JIRA JPA_SPEC-76

@lukasj
Copy link
Contributor Author

lukasj commented Jun 21, 2017

@andyjefferson Commented
Here you go, just specify this BNF,

orderby_clause ::= ORDER BY orderby_item {, orderby_item}*
orderby_item ::={ state_field_path_expression | general_identification_variable | result_variable } [ASC | DESC] [NULLS FIRST | NULLS LAST]

"The keywords "NULLS FIRST" or "NULLS LAST" defines where nulls are placed in the ordering of that item. No specification of nulls means that the ordering when the item is null is undefined."

Then you'll have what any sane JPA provider would have implemented years ago.
Can't be that controversial can it?

@lukasj
Copy link
Contributor Author

lukasj commented Aug 31, 2018

@odrotbohm
Copy link

Is there a chance, this get's prioritized for JakartaEE 10? Users of Spring Data JPA and downstream projects have been repeatedly and patiently asked for this for years, and it's a severe limitation compared to accessing other store types.

@beikov
Copy link

beikov commented Oct 20, 2021

AFAIU the community can just take over here and provide a specification, API and TCK update. We are willing to implement the JPA Criteria changes for Hibernate to serve as compatible implementation.

@beikov
Copy link

beikov commented Mar 18, 2022

If anyone is willing to work on this, Hibernate can serve as a compatible implementation.

@opengeekv2
Copy link

How hard would it be to take this on as a new (and ocasional) contributor?

@gavinking
Copy link
Contributor

I have proposed a solution in #440.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants