-->
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: How to convert this HQL to DetachedCriteria?
PostPosted: Mon Feb 14, 2011 9:06 am 
Newbie

Joined: Mon Feb 14, 2011 9:00 am
Posts: 1
This HQL statement, when executed produces this the following result:

Code:
select t, count(s) from Submission s right join s.Topics as t GROUP BY t.Id

result[0]
    [0] topic A
    [1] 10

result[1]
    [0] topic B
    [1] 12
     .
result[n]
    [0] topic N
    [1] 19

This DetachedCriteria API produces almost similar result but without loading the topic

Code:
ProjectionList PrjList = Projections.ProjectionList();
PrjList.Add(Projections.GroupProperty("Topics"), "t");
PrjList.Add(Projections.Count("Id"));

DetachedCriteria Filter = DetachedCriteria.For<Submission>();
Filter.CreateCriteria("Topics", "t", JoinType.RightOuterJoin);
Filter.SetProjection(PrjList);

result[0]
    [0] null
    [1] 10

result[1]
    [0] null
    [1] 12
     .
result[n]
    [0] null
    [1] 19

For some reason Nhibernate refuses to create topic objects for the result set but it does for the HQL. How should I alter the DetachedCriteria to get the same result?


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.