Package org.hibernate.annotations
Annotation Type OrderBy
-
@Target({METHOD,FIELD}) @Retention(RUNTIME) @Deprecated(since="6.3", forRemoval=true) public @interface OrderBy
Deprecated, for removal: This API element is subject to removal in a future version.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
SetorMap, the order is maintained using aLinkedHashSetorLinkedHashMap. If the collection is a bag orList, the order is maintained by the underlyingArrayList.There are several other ways to order or sort a collection:
- Use the JPA-defined
OrderByannotation to order using an expression written in HQL/JPQL. Since HQL is more portable between databases, this is the preferred alternative most of the time. - Use
SortComparatorto sort the collection in memory using aComparator, orSortNaturalto sort the collection in memory according to its natural order. - Use
OrderColumnto maintain the order of aListwith a dedicated index column.
It's illegal to use
OrderBytogether with the JPA-definedOrderByfor the same collection.- See Also:
OrderBy,SortComparator,SortNatural,DialectOverride.OrderBy
- Use the JPA-defined
-
-
Element Detail
-
clause
String clause
Deprecated, for removal: This API element is subject to removal in a future version.The native SQL expression used to sort the collection elements.
-
-