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.  [ 1 post ] 
Author Message
 Post subject: Count with deep implicit join in NHibernate 2 alpha 1
PostPosted: Tue Jun 17, 2008 7:01 am 
Newbie

Joined: Tue Jun 17, 2008 6:43 am
Posts: 1
Hi everyone,

I'm trying to perform a count(*) along the lines of (psuedo-sql):

Code:
SELECT count(*) FROM GrandChildEntity WHERE ChildEntity.Entity.String = 'foo'


When the implicit join is only one deep (i.e. FROM ChildEntity WHERE Entity.String = 'foo') then all is fine and I get a query which looks like:

Code:
SELECT count(*) as y0_ FROM IChildEntity this_
inner join IEntity entity1_ on
this_.Entity=entity1_.Id WHERE entity1_.String = ?}


However, when I alias the grandchild, the inner join is not getting generated so the query fails:

Code:
SELECT count(*) as y0_ FROM IGrandChildEntity this_ WHERE childentit1_.String = @p0


Do I need to treat deep joins differently when creating the criteria (doing it using ICritera API)? Looking through the code, CriteriaJoinWalker.GetJoinType() will always return null (when I think it should return Join) because the alias path is not a direct association and the query contains a 'count()' projection.

Performing a select operation using the same criteria works.

Many thanks for any help with this,

Will Holley


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

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.