Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

two improvements to doc for HQL 'order by' #10849

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

Merged
gavinking merged 1 commit into hibernate:main from gavinking:order-by-doc
Aug 31, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,8 @@ Even the identification variable of an entity with a sortable identifier type ma
[NOTE]
====
The JPQL specification requires that every sorted item in the `order by` clause also occur in the `select` clause.
HQL does not enforce this restriction, but applications desiring database portability should be aware that some databases _do_.
HQL does not enforce this restriction, but if you desire cross-database portability, you should be aware that some databases _do_.
And even databases which don't usually enforce this restriction do enforce it for `distinct` queries.

Therefore, you might wish to avoid the use of complex expressions in the sort list.
====
Expand Down Expand Up @@ -615,6 +616,12 @@ having year(order.dateTime) > 2000
order by yearlyTotalSold desc, year desc
----

[TIP]
====
If a query doesn't explicitly specify `nulls first` or `nulls last`, then, by default, the precedence of null values depends on the database.
To obtain platform-independent behavior for queries which don't specify `nulls first` or `nulls last`, set the configuration property `hibernate.order_by.default_null_ordering` to `first` or `last`.
====

Queries with an ordered result list may have limits or pagination.

[[limit-offset]]
Expand Down
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -3902,7 +3902,8 @@ Even the identification variable of an entity with a sortable identifier type ma
[NOTE]
====
The JPQL specification requires that every sorted item in the `order by` clause also occur in the `select` clause.
HQL does not enforce this restriction, but applications desiring database portability should be aware that some databases _do_.
HQL does not enforce this restriction, but if you desire cross-database portability, you should be aware that some databases _do_.
And even databases which don't usually enforce this restriction do enforce it for `distinct` queries.

Therefore, you might wish to avoid the use of complex expressions in the sort list.
====
Expand Down

AltStyle によって変換されたページ (->オリジナル) /