-->
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.  [ 6 posts ] 
Author Message
 Post subject: basic HQL join question
PostPosted: Tue Apr 11, 2006 7:41 pm 
Beginner
Beginner

Joined: Wed Apr 05, 2006 8:16 pm
Posts: 20
Hi,

I'm trying to get this query back:

Query q = aSession.createQuery("select ma.affiliate from ModuleAffiliate ma left join fetch ma.affiliate where ma.module.id = 10");

But for some reason the generated sql puts in a weird comma:

select affiliate1_.id as id0_, (a lotta fields...), affiliate1_.z_updt as z6_11_1_ from module_affiliate moduleaffi0_, left outer join affiliate affiliate1_ on moduleaffi0_.affiliateId=affiliate1_.id where moduleaffi0_.moduleId=10

Just removing the comma at the end of "from module_affiliate moduleaffi0_, " in the statement makes the query work OK in MySQL Query Browser. Am I making a mistake in my HQL that is causing the comma to show up? Thanks for any answers and/or just reading this far!:),

Jim


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 12, 2006 2:23 am 
Newbie

Joined: Sat Nov 22, 2003 9:21 pm
Posts: 18
Location: Malaysia
Hi,

Why don't u do this instead:
Code:
Query q = aSession.createQuery("select aff from ModuleAffiliate ma left join ma.affiliate AS aff where ma.module.id = 10");


Regards,
Edward


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 12, 2006 4:20 am 
Regular
Regular

Joined: Wed Aug 25, 2004 6:23 am
Posts: 91
What version are you using? There have been a few bugs of that kind fixed in recent versions.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 12, 2006 4:32 am 
Newbie

Joined: Sat Nov 22, 2003 9:21 pm
Posts: 18
Location: Malaysia
3.1.2


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 12, 2006 8:53 am 
Senior
Senior

Joined: Wed Aug 17, 2005 12:56 pm
Posts: 136
Location: Erie, PA (USA)
I have seen this when you specify a "fetch" join in HQL and the association (in the mapping) is already a "fetch". As a work-around, remove the key word "FETCH" from HQL.

Curtis ...


Top
 Profile  
 
 Post subject: Thanks!
PostPosted: Wed Apr 12, 2006 10:38 am 
Beginner
Beginner

Joined: Wed Apr 05, 2006 8:16 pm
Posts: 20
Thank you -- removing the fetch and making it a simple join worked out !


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