-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: HQL for querying collection
PostPosted: Wed Mar 21, 2007 3:51 pm 
Newbie

Joined: Thu Nov 16, 2006 4:17 pm
Posts: 5
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


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 22, 2007 3:12 am 
Expert
Expert

Joined: Tue Dec 28, 2004 7:02 am
Posts: 573
Location: Toulouse, France
Well, your HQL:
Quote:
select allExams
from Exams.Domain.ExamImpl allExams
join allExams.ExamAccess examAdmins
where examAdmins.EmployeeId = <someid>

uses a join... So it generates a join. I don't understand why you're surprised?

_________________
Baptiste
PS : please don't forget to give credits below if you found this answer useful :)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 22, 2007 5:09 am 
Regular
Regular

Joined: Tue Aug 08, 2006 4:28 am
Posts: 96
Location: Hong Kong
Sandeep, would you post the mapping files?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.