I have a one-to-many object association (Customer --> Invoice) where I want to create a HQL query that retrieves all the customer objects with the most recent customer invoice.
For example...
Code:
public class Customer {
...
private int fCustomerID;
private String fCustomerName;
...
}
public class Invoice {
...
private int fInvoiceID;
private Data fInvoiceDate
private double fInvoiceAmount;
private int fCustomerID;
...
}
My query should return an array of two objects
* Customer object
* Most recent customer invoice, or null if not found
My starting query is...
Code:
from Customer as customer,
Invoice as invoice
left join customer.customerID = invoice.customer
... but it's not clear to me how or where I would restrict the left join so that only the most invoice is returned.
Any ideas?