There are some examples of CriteriaQuery.join() calls in the Criteria API documentation.
Neither CriteriaQuery nor its superinterface AbstractQuery have a join() method.
These local variables should refer to the root node "pet" instead of the CriteriaQuery "cq".
Occurences in "Using the Criteria API and Metamodel API to Create Basic Typesafe Queries":
"Querying Relationships Using Joins":
Join<Owner, Address> address = cq.join(Pet_.owners).join(Owner_.addresses);
Join<Owner, Address> address = cq.join(Pet_.owners).join(Owner_.address);
Join<Pet, Owner> owner = cq.join(Pet_.owners);