I am currently working on Nhibernate/AndroMDA snapshot 3.2 with Microsoft .NET and have some problems in the
implementation of the SQL queries, more precisely with column aliasing.
for e.g,
IQuery query = session.CreateQuery("select (User.Firstname +' '+User.lastname) as {User.username} from UserImpl User");
The user's last name and first name have been concatenated into one field, username. This field is then returned to the calling application as a single column.
I am getting the following errors:
NHibernate.QueryException: ", expected in SELECT [select (User.Firstname +' '+User.lastname) as {User.username} from AliasPrototype.Domain.UserImpl User
at NHibernate.Hql.SelectParser.Token(String token, QueryTranslator q)
at NHibernate.Hql.ClauseParser.Token(String token, QueryTranslator q)
at NHibernate.Hql.ClauseParser.End(QueryTranslator q)
at NHibernate.Hql.PreprocessingParser.End(QueryTranslator q)
at NHibernate.Hql.ParserHelper.Parse(IParser p, String text, String seperators, QueryTranslator q)
at NHibernate.Hql.QueryTranslator.Compile()
at NHibernate.Hql.QueryTranslator.Compile(ISessionFactoryImplementor factory, IDictionary replacements, Boolean scalar)
at NHibernate.Impl.SessionFactoryImpl.GetQuery(String queryString, Boolean shallow)
at NHibernate.Impl.SessionImpl.GetQueries(String query, Boolean scalar)
at NHibernate.Impl.SessionImpl.Find(String query, QueryParameters parameters)
at NHibernate.Impl.QueryImpl.List()
at AliasPrototype.Service.EmployeeServiceImpl"
Is it possible to perform column aliasing using CreateQuery() method in Nhibernate?
If not, which particular method should I use to carry out this task?
Your help will be highly appreciated
|