select month(ro.Something) from RisingOrder ro group by month(ro.Something)
2009/7/8 Darius Damalakas <[email protected]> > > My ultimate goal is: to group my query by month. Month is extracted > from property Client.ObjectCreateDate using registered sql function > "month". The HQL counterpart works fine, but i need to write this > with ICriteria API. > > My exact question and problem is this: why the below query does not > generate SQL statement with correct alias? That is, the resulted alias > is 'y0_' even though i specify a different one. > > This is the resulted SQL: > > SELECT extract(month from this_.OBJECT_CREATE_DATE) as y0_ FROM > CLIENTS this_ > > This is the Criteria query that generates it: > > DetachedCriteria.For(typeof(RisingOrder)) > .SetProjection(Projections.ProjectionList() > .Add(Projections.SqlFunction("month", > NHibernateUtil.Int32, Property.ForName("ObjectCreateDate")), > "mmonth")) > .GetExecutableCriteria(session) > .List(); > > > > > Looking at NHibernate source code (which is tricky, at least with how > aliases are processed), i found that for example in Order.cs:58, > columns aliases are retrieved by accessing ICriteriaQuery, that is : > string[] columns = criteriaQuery.GetColumnAliasesUsingProjection > (criteria, propertyName); > > > However, in SqlFunctionProjection.cs:96, aliases are retrieved by > calling base function like this: > sb.Add(GetColumnAliases(position)[0]); > > Should not it be something similar like > sb.Add(criteriaQuery.GetColumnAliasesUsingProjection(criteria, > someProperty)); > or > sb.Add(args[0].Aliases); > > > > > > > > -- Fabio Maulo --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nhusers?hl=en -~----------~----~----~----~------~----~------~--~---
