Hibernate version:2.1.6
Hi, I'm trying to do a combination of Query by Example and some Expressions..
I have 4 classes:
- Company (has a set of "Agencies")
- Agency (has a component "Address")
- Address (a component having a "Zipcode" object among others)
- Zipcode
What I need to do is, to recieve a Company object to use as example and to receive the Zipcode object, to know what company has agencies in that area.
As you can see, the navigation here is company.agencies.address.zipcode.
Looking through the hibernate_docs I could find how to get there using the Criteria API.
I have something like this:
Criteria criteria = sess.createCriteria(Company.class);
criteria.add( Example.create(company) );
criteria.createCriteria("agencies.Address").add(Expression.eq("zipcode", zipcode));
Any help would be much appreciated!
|