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; }
reference http://www.objectdb.com/api/java/jpa/OrderBy
Comments
Post a Comment