I have an object Dog which holds a set of DogMetadata.
Each DogMetadata has two values: a String ("desc") and an int ("rank").
Descriptions of dogs have different rankings such as: "small" is 5, "furry" is 2, "friendly" is 9, "dalmation" is 11, "mutt" is 22.
I need to search for dogs based on any of their desc values (for example, find "furry" OR "small" dogs).
This query returns the matching dogs, but they are not in any order.
Code:
select distinct Dog as d
left join d.dogMetadata as dMeta
where ( (dMeta.desc = 'furry') OR (dMeta.desc = 'small') )
How do I order the list of matching Dog objects by the total "rank" values of any matching DogMetadatas?
I've been working like a dog on this all day (trying "Group By" and "Order By") but I think I have been barking up the wrong tree.