Given
{code:java}@Entity(name = "Parent") public static class Parent { .... @OneToMany(mappedBy = "parent", cascade = CascadeType.ALL) @Fetch(value = FetchMode.SUBSELECT) @OrderBy("name ASC") private List<Child> children = new ArrayList<>(); }
@Entity(name = "Child") public static class Child { ...
@ManyToOne(cascade = CascadeType.ALL) @JoinColumn(name = "parent_id", nullable = false) private Parent parent; } {code}
the query
{code:java}List<Parent> parents = session.createQuery( "select p from Parent p", Parent.class ).list();{code}
does not return the children ordered by name; |
|