I am trying to return a List of Objects with the following HQL-Statement:
return getHibernateTemplate().findByNamedParam("Select distinct response.user
from Survey survey
inner join fetch survey.surveyDates surveyDate
inner join fetch surveyDate.responses response
where survey.id = :surveyId)", "surveyId", surveyId);
The following error drives me mad:
HTTP Status 500 - query specified join fetching, but the owner of the fetched association was not present in the select list
So I tried it without the word "fetch" in my code. Then my returning list is empty.
The Application is like Doodle, the Database looks like this:
Survey has a list surveyDates
SurveyDate has a list of responses
Response has an attribute user
My task was: The method has a parameter surveyId and returns all users, that responded to it. So we have to go down all the way Survey --> surveyDates --> responses --> user
I guess thats pretty easy for you, i am new to SQL and even newer to Hibernate!