javax.persistence

Annotation Type OrderBy


  • @Target(value={METHOD,FIELD})
     @Retention(value=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:

        orderby_list::= orderby_item [,orderby_item]*
        orderby_item::= [property_or_field_name] [ASC | DESC]
     

    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 will be 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.

        Example 1:
        
        @Entity 
        public class Course {
           ...
           @ManyToMany
           @OrderBy("lastname ASC")
           public List<Student> getStudents() {...};
           ...
        }
        
        Example 2:
    
        @Entity 
        public class Student {
           ...
           @ManyToMany(mappedBy="students")
           @OrderBy // ordering by primary key is assumed
           public List<Course> getCourses() {...};
           ...
        }
    
        Example 3: 
    
        @Entity 
        public class Person {
             ...
           @ElementCollection
           @OrderBy("zipcode.zip, zipcode.plusFour")
           public Set<Address> getResidences() {...};
           ...
        }
      
        @Embeddable 
        public class Address {
           protected String street;
           protected String city;
           protected String state;
           @Embedded protected Zipcode zipcode;
        }
    
        @Embeddable 
        public class Zipcode {
           protected String zip;
           protected String plusFour;
        }
     
    Since:
    Java Persistence 1.0
    See Also:
    OrderColumn
    • Element Detail

      • value

        public abstract String value
        An orderby_list. Specified as follows:
            orderby_list::= orderby_item [,orderby_item]*
            orderby_item::= [property_or_field_name] [ASC | DESC]
         

        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:
        ""

Deutsche Übersetzung

Sie haben gebeten, diese Seite auf Deutsch zu besuchen. Momentan ist nur die Oberfläche übersetzt, aber noch nicht der gesamte Inhalt.

Wenn Sie mir bei Übersetzungen helfen wollen, ist Ihr Beitrag willkommen. Alles, was Sie tun müssen, ist, sich auf der Website zu registrieren und mir eine Nachricht zu schicken, in der Sie gebeten werden, Sie der Gruppe der Übersetzer hinzuzufügen, die Ihnen die Möglichkeit gibt, die gewünschten Seiten zu übersetzen. Ein Link am Ende jeder übersetzten Seite zeigt an, dass Sie der Übersetzer sind und einen Link zu Ihrem Profil haben.

Vielen Dank im Voraus.

Dokument erstellt 11/06/2005, zuletzt geändert 18/08/2025
Quelle des gedruckten Dokuments:https://www.gaudry.be/de/java-api-javaee-rf-javax/persistence/orderby.html

Die Infobro ist eine persönliche Seite, deren Inhalt in meiner alleinigen Verantwortung liegt. Der Text ist unter der CreativeCommons-Lizenz (BY-NC-SA) verfügbar. Weitere Informationen auf die Nutzungsbedingungen und dem Autor.

Referenzen

  1. Zeigen Sie - html-Dokument Sprache des Dokuments:fr Manuel PHP : https://docs.oracle.com

Diese Verweise und Links verweisen auf Dokumente, die während des Schreibens dieser Seite konsultiert wurden, oder die zusätzliche Informationen liefern können, aber die Autoren dieser Quellen können nicht für den Inhalt dieser Seite verantwortlich gemacht werden.
Der Autor dieser Website ist allein dafür verantwortlich, wie die verschiedenen Konzepte und Freiheiten, die mit den Nachschlagewerken gemacht werden, hier dargestellt werden. Denken Sie daran, dass Sie mehrere Quellinformationen austauschen müssen, um das Risiko von Fehlern zu reduzieren.