I would like to express the following sql query with hibernate criteria but I don't know if it is possible:
SELECT person.name, COUNT(person_addresses.address_id) FROM person LEFT JOIN person_addresses ON person_addresses.person_id=person.id GROUP BY person.name ORDER BY COUNT(person_addresses.address_id) DESC
I have a class "person" (with field id and name, and a list of addresses) and a class "adress" (with id, street,...) I have 3 tables in the DB: - person (id, name) - person_addresses (person_id, address_id) - address (id, street, ...)
Thanks for the help
|