Top Description Methods
org.hibernate.annotations

public @Interface OrderBy

extends Annotation
Annotations
@Target:METHOD, FIELD
@Retention:RUNTIME
@Deprecated
since:6.3
forRemoval:true
Imports
java.lang.annotation.Retention, .Target

Deprecated

for removal since 6.3.

Use SQLOrder instead. This annotation will be removed eventually, since its unqualified name collides with jakarta.persistence.OrderBy.

Order a collection using an expression written in native SQL.

The order is applied by the database when the collection is fetched, but is not maintained by operations that mutate the collection in memory.

If the collection is a java.util.Set or java.util.Map, the order is maintained using a java.util.LinkedHashSet or java.util.LinkedHashMap. If the collection is a bag or java.util.List, the order is maintained by the underlying java.util.ArrayList.

There are several other ways to order or sort a collection:

It's illegal to use OrderBy together with the JPA-defined jakarta.persistence.OrderBy for the same collection.

Authors
Emmanuel Bernard, Steve Ebersole
See Also
jakarta.persistence.OrderBy, SortComparator, SortNatural, DialectOverride.OrderBy

Method Summary

Modifier and TypeMethod and Description
public String
clause()

The native SQL expression used to sort the collection elements.

Inherited from java.lang.annotation.Annotation:
annotationTypeequalshashCodetoString

Method Detail

clauseback to summary
public String clause()

The native SQL expression used to sort the collection elements.