-->
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.  [ 2 posts ] 
Author Message
 Post subject: Query Question
PostPosted: Wed Dec 21, 2005 12:49 pm 
I am working on a query for NHibernate that needs to generate SQL that performs a join on multiple Keys. This is the query we thought would
work, but apparently the ON Syntax is incorrect.


Code:
SELECT tmpLocalizedLearningObjects, tmpLearningObjectsSession
FROM GeoLearning.Core.Course AS tmpCourse
JOIN tmpCourse.LearningObjects AS tmpLearningObjects
JOIN tmpLearningObjects.LocalizedLearningObjects AS tmpLocalizedLearningObjects
JOIN tmpLocalizedLearningObjects.AvailableCulture AS tmpAvailableCulture
JOIN tmpAvailableCulture.Language AS tmpLanguage
JOIN tmpAvailableCulture.Country AS tmpCountry
LEFT OUTER JOIN tmpLearningObjects.LearningObjectHasLearningObjectSessions AS tmpLearningObjectHasLearningObjectSessions
LEFT OUTER JOIN tmpLearningObjectHasLearningObjectSessions.LearningObjectSession AS tmpLearningObjectsSession
ON tmpLearningObjectsSession.Id=tmpLearningObjectHasLearningObjectSessions.LearningObjectsSessionId
AND tmpLearningObjectsSession.UserId = '499efa8d-07b4-4131-8d27-099fe3ea0d11'
WHERE tmpCourse.Id = 'bda1d519-ebd0-45eb-a842-4d407a8c8bec'
AND tmpLanguage.Code = 'en'
AND tmpCountry.Code = 'US'


We recieve a
Code:
NHibernate.QueryException: unexpected token: ON [<Query Omitted for post>]

Is there another way to achieve this query?

-Steve Nelson
snelson@geolearning.com


Top
  
 
 Post subject:
PostPosted: Tue Dec 27, 2005 3:11 pm 
Regular
Regular

Joined: Fri Sep 09, 2005 11:35 am
Posts: 101
i think hql does not support on clause yet. you may be able to use your dialect specific outer join syntax to do this.

SELECT tmpLocalizedLearningObjects, tmpLearningObjectsSession
FROM GeoLearning.Core.Course AS tmpCourse
JOIN tmpCourse.LearningObjects AS tmpLearningObjects
JOIN tmpLearningObjects.LocalizedLearningObjects AS tmpLocalizedLearningObjects
JOIN tmpLocalizedLearningObjects.AvailableCulture AS tmpAvailableCulture
JOIN tmpAvailableCulture.Language AS tmpLanguage
JOIN tmpAvailableCulture.Country AS tmpCountry
LEFT OUTER JOIN tmpLearningObjects.LearningObjectHasLearningObjectSessions AS tmpLearningObjectHasLearningObjectSessions
,tmpLearningObjectHasLearningObjectSessions.LearningObjectSession AS tmpLearningObjectsSession
WHERE tmpCourse.Id = 'bda1d519-ebd0-45eb-a842-4d407a8c8bec'
AND tmpLanguage.Code = 'en'
AND tmpCountry.Code = 'US'
AND
tmpLearningObjectsSession.Id=tmpLearningObjectHasLearningObjectSessions.LearningObjectsSessionId
AND tmpLearningObjectsSession.UserId = '499efa8d-07b4-4131-8d27-099fe3ea0d11'


replace the where clause portion to as you would do a native outer join in your database.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.