-->
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.  [ 2 posts ] 
Author Message
 Post subject: column aliasing
PostPosted: Wed Nov 01, 2006 1:01 am 
Newbie

Joined: Wed Nov 01, 2006 12:29 am
Posts: 1
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


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 01, 2006 2:59 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
You should be using CreateSQLQuery, not CreateQuery.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

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.