If you need to select a new object you can use the "select new Cat(c.x, c.y, c.z) from Cat c where ... ". Aliases is not useful when doing a simple select. Otherwise you can use the Criteria API and do a projection instead.
Unfortunately it seems like HQL and Criteria API supports different features. But perhaps that's the point. 2009/3/30 Fethi Gürcan <[email protected]> > Hello, > > i'm newbie in nhibernate and i've 2 simple question. > > 1) i'm trying some simple HQL queries for learning querying in hibernate. > > "select c.Id, c.PlakaNo, c.Name from Il c" > (selected columns are less than the table's original, so it returns > IList<object[]>) > > this is a simple query that i run. > > But when i add some aliases like this: "select c.Id as xx, c.PlakaNo as yy, > c.Name as zz from Il c" > > it throws this exception : " ',' expected in SELECT before:as [select c.Id > as xx, c.PlakaNo as yy, c.Name as zz from Il c] " > > i see many samples that uses column aliases. > > what's the point that i missed? > > and after that. > > 2) It seems i have to use IResultTransformer for "custom" query results > (for search results, lists etc.) for trnasforming well defined generic > list<DTO>. > (and it seems Transformers.AliasToBean() needs aliases for work right?) > > Note: i can't run the AliasToEntity() cause question (1). But i'd write my > own custom IResultTransformer class successfully. But i think it is not the > good choice in many cases. > (this approach needs Trasformer for each individual DTOs) > > First: is it the main approach for results like this example? > Second: or what is the main approach that are you using? > > Thanks > > > > > > > > > > -- > Fethi Gürcan > > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
