How do you order a oneToMany join table in hibernate criteria
You need to add the @javax.persistence.OrderBy
annotation to your kittens
list.
@OneToMany(fetch = FetchType.LAZY,
targetEntity=Kittens.class,
cascade=CascadeType.ALL)
@JoinColumn(name="motherId")
@OrderBy("kittenName")
private List<Kittens> kittens;
@See
- Hibernate Annotations Reference Guide
- Chapter 2.2.5. Mapping entity associations/relationships
- Subchapter 2.2.5.3.4. Indexed collections (List, Map)