Say I have the following entities
class Order {
@Id
private long id;
private long orderNo;
@OneToMany
@JoinColumn(name="order_id")
@OrderBy("timeStamp ASC")
private List<Item> items;
}
class Item {
@Id
private long id;
// e.g. COMPLETED, IN PROGRESS, QUEUED, etc...
private String status;
private long timeStamp;
@ManyToOne
private Order order;
}
Using JPA I want to return a list of Orders that are sorted by the status from the last Item in the items list, which is the most recent one since items is order by timeStamp. How can this be done?