I am using Hibernate3 (with the Spring Framework), and I am trying to build a criteria that would join a table/class just using the ID.
For example: let's say I have a class "Sale" that has an attribute "customerId". I also have a class "Customer" (and it has an attribute "city").
(Yes, the mapping file for Sale doesn't have a property for Customer, but customerId).
If I wanted to get the list of Sales that were made by Customers in New York, how would I be able to go about that using a Criteria?
Thanks in advance, Andy
PS. This is what I'm starting with:
Code:
DetachedCriteria criteria = DetachedCriteria.forClass(Sale.class, "s");
Something like wouldn't be useful, right?:
Code:
DetachedCriteria customerCriteria = DetachedCriteria.forClass(Customer.class, "c");
customerCriteria.add( Restrictions.eqProperty("s.customerId", "c.id") );