I'm trying to write a query in HQL, and I'm having some trouble with it. It's probably not too difficult, but I'm pretty awful at query languages in general and HQL in specific.
Basically, there are three tables, Owners, Pets, and Toys, whose classes look like this:
public class Owner {
long ownerId;
List<Pet> pets;
}
public class Pet {
Owner myOwner;
List<Toy> toys;
}
public class Toy {
Pet petThatOwnsThisToy;
boolean isSqueaky;
}
I'm looking for a HQL query that, given an Owner, returns the number of their pets that have at least 3 squeaky toys. I'm sure there's gotta be a pretty simple HQL way to solve this, but search me if I know what it is.
I'd also be happy to discover any helpful HQL tutorials beyond the documentation (which is excellent, assuming one is already an SQL pro, which I'm not).