jpa criteria-api: join with subselect
问题 This query is used to retrieve last records in a one-to-many relationship (see SQL join: selecting the last records in a one-to-many relationship) SELECT p.* FROM customer c INNER JOIN ( SELECT customer_id, MAX(date) MaxDate FROM purchase GROUP BY customer_id ) MaxDates ON c.id = MaxDates.customer_id INNER JOIN purchase p ON MaxDates.customer_id = p.customer_id AND MaxDates.MaxDate = p.date; My question: How can I build this join with the subselect with the jpa criteria-api? Is it possible?