Hi,
I've an Exam entity with one of the attributes being a Set of another entity called ExamAccess. ExamAccess stores only employee ids who are administrators to any exam. An exam can have multiple administrators.
My problem is while querying the database using HQL to get a list of exams whose administrator is a particular employee!
I'm trying to accomplish this with the following query but, I get an error "Invalid Object name"
HQL:
Code:
select allExams
from Exams.Domain.ExamImpl allExams
join allExams.ExamAccess examAdmins
where examAdmins.EmployeeId = <someid>
Full stack trace of any exception that occurs:It generates the following SQL out of it.
Code:
select examimpl0_.ID as ID, examimpl0_.PERIODICITY_FK as PERIODI10_, examimpl0_.LOCATION_FK as LOCATION9_, examimpl0_.TITLE as TITLE, examimpl0_.DELINQUENCY_NOTIFICATION_FLAG as DELINQUE5_, examimpl0_.SHOW_WRONG_ANSWERS_FLAG as SHOW_WRO3_, examimpl0_.EXAM_TYPE_FK as EXAM_TYP8_, examimpl0_.SHOW_SCORE_FLAG as SHOW_SCO4_, examimpl0_.RETEST_POLICY_FK as RETEST_P7_, examimpl0_.TIMED_FLAG as TIMED_FLAG
from EXAM examimpl0_ inner join EXAM_ACCESS2EXAMS examaccess1_ on examimpl0_.ID=examaccess1_.EXAMS_FK inner join EXAM_ACCESS examaccess2_ on examaccess1_.EXAM_ACCESS_FK=examaccess2_.ID
where (examaccess2_.EMPLOYEE_ID=351)
If you look at it closely, in the from clause, if you remove this line ...
Code:
inner join EXAM_ACCESS2EXAMS examaccess1_ on examimpl0_.ID=examaccess1_.EXAMS_FK
then the remainder query is what I need. I can't figure out why is this happening!!!
Any help is appreciated
Thanks,
Sandeep