Annotation Interface OrderBy


@Target({METHOD,FIELD}) @Retention(RUNTIME) public @interface OrderBy
Specifies the ordering of the elements of a collection-valued association or element collection at the point when the association or collection is retrieved.

The syntax of the value ordering element is an orderby_list, as follows:

If ASC or DESC is not specified, ASC (ascending order) is assumed.

If the ordering element is not specified for an entity association, ordering by the primary key of the associated entity is assumed.

The property or field name must correspond to that of a persistent property or field of the associated class or embedded class within it. The properties or fields used in the ordering must correspond to columns for which comparison operators are supported.

The dot (.) notation is used to refer to an attribute within an embedded attribute. The value of each identifier used with the dot notation is the name of the respective embedded field or property.

The OrderBy annotation may be applied to an element collection. When OrderBy is applied to an element collection of basic type, the ordering is by value of the basic objects and the property or field name is not used. When specifying an ordering over an element collection of embeddable type, the dot notation must be used to specify the attribute or attributes that determine the ordering.

The OrderBy annotation is not used when an order column is specified using OrderColumn.

Example 1:

Example 2:

Example 3:

Since:
1.0
See Also:
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    An orderby_list.
  • Element Details

    • value

      String value
      An orderby_list. Specified as follows:

      If ASC or DESC is not specified, ASC (ascending order) is assumed.

      If the ordering element is not specified, ordering by the primary key of the associated entity is assumed.

      Default:
      ""