When doing a findById() call, the function returned an integer breaking the conditions inside generateQuery().