@Override
    public Pet findById(int id) {
        int ownerId;
        try {
            ownerId = this.jdbcClient
                .sql("SELECT owner_id FROM pets WHERE id=:id")
                .param("id", id)
                .query(Integer.class)
                .single();
        } catch (EmptyResultDataAccessException ex) {
            throw new ObjectRetrievalFailureException(Pet.class, id);
        }
        Owner owner = this.ownerRepository.findById(ownerId);
        return EntityUtils.getById(owner.getPets(), Pet.class, id);
    }
@author Ken Krebs
@author Juergen Hoeller
@author Rob Harrop
@author Sam Brannen
@author Thomas Risberg
@author Mark Fisher
@author Antoine Rey
src/main/java/org/springframework/samples/petclinic/repository/jdbc/JdbcPetRepositoryImpl.java