Hi Cameron,
thanks for your reply.
The major problem what I want to be solved is the possibility to fetch several objects like I can do in HQL
Code:
SELECT i, b ...
The criteria API only provides createCriteria(Class clazz) on a single class and retrieves a list of this class.
But, what I want to retrieve is a List<Object[]>.
The example above was not quite good, lets try again
Code:
SELECT u, a, s
FROM User u
LEFT JOIN u.addresses a
LEFT JOIN u.shipments s
WHERE
a.street = s.street
AND a.zip = s.zip
With the criteria API it would look like this
Code:
Criteria usersCrit = session.createCriteria(User.class);
usersCrit.createAlias("addresses", "a");
usersCrit.createAlias("shipments", "s");
usersCrit.add(Restrictions.eqProperty("a.street", "s.street");
List<User> users = usersCrit.list();
Now I have to search within the shipments and the addresses of the users returned by the list() for equality of zip and street.
In HQL I'll get an Object[] containing the user, address and shipment without searching.
How can I do this with the criteria API?
Best regards
Joerg