Top Description Inners Methods
jakarta.data.repository

public @Interface OrderBy

extends Annotation
Annotations
@Repeatable:List
@Retention:RUNTIME
@Target:METHOD
Imports
jakarta.data.Order, .Sort, java.lang.annotation.ElementType, .Repeatable, .Retention, .RetentionPolicy, .Target

Annotates a repository method to request sorting of results.

When multiple OrderBy annotations are specified on a repository method, the precedence for sorting follows the order in which the OrderBy annotations are specified, and after that follows any sort criteria that are supplied dynamically by Sort parameters or by any Order parameter.

For example, the following sorts first by the lastName attribute in ascending order, and secondly, for entities with the same lastName, it then sorts by the firstName attribute, also in ascending order. For entities with the same lastName and firstName.

@OrderBy("lastName")
@OrderBy("firstName")
@OrderBy("id")
Person[] findByZipCode(int zipCode, PageRequest pageRequest);

The interpretation of ascending and descending order is determined by the database, but, in general:

A repository method with an @OrderBy annotation must not have:

A Jakarta Data provider is permitted to reject such a repository method declaration at compile time or to implement the method to throw UnsupportedOperationException.

A repository method will fail with a DataException or a more specific subclass if the database is incapable of ordering with the requested sort criteria.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static @interface
OrderBy.List

Enables multiple OrderBy annotations on the method.

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

whether to use descending (versus ascending) order.
descending
()

Indicate whether to use descending order when sorting by this attribute.

public boolean

Returns:

whether or not to request case insensitive sorting for the property.
ignoreCase
()

Indicates whether or not to request case insensitive ordering from a database with case sensitive collation.

public String

Returns:

entity attribute name.
value
()

Entity attribute name to sort by.

Inherited from java.lang.annotation.Annotation:
annotationTypeequalshashCodetoString

Method Detail

descendingback to summary
public boolean descending()

Indicate whether to use descending order when sorting by this attribute.

The default value of false means ascending sort.

Returns:boolean

whether to use descending (versus ascending) order.

ignoreCaseback to summary
public boolean ignoreCase()

Indicates whether or not to request case insensitive ordering from a database with case sensitive collation. A database with case insensitive collation performs case insensitive ordering regardless of the requested ignoreCase value.

The default value is false.

Returns:boolean

whether or not to request case insensitive sorting for the property.

valueback to summary
public String value()

Entity attribute name to sort by.

For example,

@OrderBy("age")
Stream<Person> findByLastName(String lastName);
Returns:String

entity attribute name.

jakarta.data.repository back to summary

public @Interface OrderBy.List

extends Annotation
Annotations
@Retention:RUNTIME
@Target:METHOD

Enables multiple OrderBy annotations on the method.

Method Summary

Modifier and TypeMethod and Description
public OrderBy[]

Returns:

list of annotations.
value
()

Returns a list of annotations with the first taking precedence, followed by the second, and so forth.

Inherited from java.lang.annotation.Annotation:
annotationTypeequalshashCodetoString

Method Detail

valueback to summary
public OrderBy[] value()

Returns a list of annotations with the first taking precedence, followed by the second, and so forth.

Returns:OrderBy[]

list of annotations.