-->
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.  [ 9 posts ] 
Author Message
 Post subject: Incorrect HQL subquery parsing!
PostPosted: Tue Feb 21, 2006 6:52 am 
Newbie

Joined: Tue Feb 21, 2006 6:46 am
Posts: 7
I have next HQL query:
Code:
select p
  from Permission p
  join fetch p.PermissionGroup pg
  join p.RolePermissionBridges rpb
where
  pg in (select pgmb.PermissionGroup.Id from Module m join m.PermissionGroupModuleBridges pgmb where m.IsAvailable = 1) and rpb.RoleId = :RoleId


And subquery in it parsed as following:
Code:
select permission4_.PermissionGroupId from dbo.prmModuleObject module3_, lnkPermissionGroupModuleObject permission4_ and permission4_.Ciid = 2 where module3_.Ciid = 2 and module3_.Id=permission4_.ModuleId and ((module3_.IsAvailable=1))


Why instead of join it puts here comma???


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 21, 2006 7:39 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
Comma is a synonym of INNER JOIN. Is there any problem when executing the query?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 21, 2006 7:58 am 
Newbie

Joined: Tue Feb 21, 2006 6:46 am
Posts: 7
sergey wrote:
Comma is a synonym of INNER JOIN. Is there any problem when executing the query?


The problem in that I need to get not:
Code:
select permission4_.PermissionGroupId from dbo.prmModuleObject module3_, lnkPermissionGroupModuleObject permission4_ and permission4_.Ciid = 2 where module3_.Ciid = 2 and module3_.Id=permission4_.ModuleId and ((module3_.IsAvailable=1))

but:
Code:
select permission4_.PermissionGroupId from dbo.prmModuleObject module3_ inner join lnkPermissionGroupModuleObject permission4_ on module3_.Id=permission4_.ModuleId and permission4_.Ciid = 2 where module3_.Ciid = 2 and ((module3_.IsAvailable=1))


How can I do this?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 21, 2006 8:05 am 
Newbie

Joined: Tue Feb 21, 2006 6:46 am
Posts: 7
Also I need to add my own condition for inner join, smth like this:

Code:
elect permission4_.PermissionGroupId from dbo.prmModuleObject module3_ inner join lnkPermissionGroupModuleObject permission4_ on module3_.Id=permission4_.ModuleId and permission4_.Ciid = 2 where module3_.Ciid = 2 and ((module3_.IsAvailable=1))


and permission4_.Ciid = 2 condition here...

I expected in this subquery inner join but have Theta-style join so if I will add this condition - this query will not work....


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 21, 2006 8:14 am 
Newbie

Joined: Tue Feb 21, 2006 6:46 am
Posts: 7
Also as I see from NHibernate source code all inner joins in subqueries are transformed to Theta-style joins - but it is not correct.

Code:
select p
from Permission p
  join fetch p.PermissionGroup pg
  join p.RolePermissionBridges rpb
where
  pg in (select pgmb.PermissionGroup.Id from Module m inner join m.PermissionGroupModuleBridges pgmb where m.IsAvailable = 1) and rpb.RoleId = :RoleId


For query above in subquery:
Code:
select pgmb.PermissionGroup.Id from Module m inner join m.PermissionGroupModuleBridges pgmb where m.IsAvailable = 1


I have exactly INNER JOIN - not smth else.....


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 21, 2006 8:39 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
Why is it not correct? For inner joins it's exactly the same whether the condition is ON or WHERE. It would only matter for outer joins.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 21, 2006 9:34 am 
Newbie

Joined: Tue Feb 21, 2006 6:46 am
Posts: 7
sergey wrote:
Why is it not correct? For inner joins it's exactly the same whether the condition is ON or WHERE. It would only matter for outer joins.


How this HQL query can be rewritten to use INNER JOIN then?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 21, 2006 10:03 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
Well, it can't.

Update: ...at least as far as I know.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 23, 2006 11:32 am 
Newbie

Joined: Tue Feb 21, 2006 6:46 am
Posts: 7
sergey wrote:
Well, it can't.

Update: ...at least as far as I know.


I've found in FromParser->Token following line of code:
Quote:
peParser.UseThetaStyleJoin = q.IsSubquery;


Will it be more correct to change it to:
Quote:
peParser.UseThetaStyleJoin = false;


and we will have implicit INNER JOIN subquery?


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