This HQL statement, when executed, produces the following result:
select t, count(s) from Submission s right join s.Topics as t GROUP BY t.Id result[0] [0] topic_id, topic_name, ... [1] 10 result[1] [0] topic_id, topic_name, ... [1] 12 . result[n] [0] topic_id, topic_name, ... [1] 19
This DetachedCriteria API produces almost the same result, but without loading a theme.
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 theme objects for a result set, but it does for an HQL query. Why is this?
c # orm hibernate nhibernate hql
Roman
source share