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.  [ 1 post ] 
Author Message
 Post subject: how to concatenate strings in select clause?
PostPosted: Wed Dec 19, 2007 8:22 am 
Newbie

Joined: Wed Dec 19, 2007 7:46 am
Posts: 1
Is it possible to concatenate strings in select clause?
if it is, how?

when i try:
Code:
IList l = session.CreateQuery(
                "SELECT pi.PATTERNTYPE || pi.PATTERNNAME " +
                "FROM PATTERNINFO as pi")
                 .SetMaxResults(5)
                 .List();


it throws a NHibernate.QueryException exception:
Code:
{", expected in SELECT [SELECT pi.PATTERNTYPE ||  pi.PATTERNNAME FROM nhtest.Objects.PATTERNINFO as pi]"}


and the stack trace is:
Code:
   at NHibernate.Hql.Classic.SelectParser.Token(String token, QueryTranslator q)
   at NHibernate.Hql.Classic.ClauseParser.Token(String token, QueryTranslator q)
   at NHibernate.Hql.Classic.ClauseParser.End(QueryTranslator q)
   at NHibernate.Hql.Classic.PreprocessingParser.End(QueryTranslator q)
   at NHibernate.Hql.Classic.ParserHelper.Parse(IParser p, String text, String seperators, QueryTranslator q)
   at NHibernate.Hql.Classic.QueryTranslator.Compile()
   at NHibernate.Hql.Classic.QueryTranslator.Compile(IDictionary replacements, Boolean scalar)
   at NHibernate.Impl.SessionFactoryImpl.GetQuery(String queryString, Boolean shallow, IDictionary enabledFilters)
   at NHibernate.Impl.SessionImpl.GetQueries(String query, Boolean scalar)
   at NHibernate.Impl.SessionImpl.Find(String query, QueryParameters parameters, IList results)
   at NHibernate.Impl.SessionImpl.Find(String query, QueryParameters parameters)
   at NHibernate.Impl.QueryImpl.List()
   at nhtest.Form1.Form1_Load(Object sender, EventArgs e) in D:\Leojay\nhtest\Form1.cs:line 55


but the statement:
Code:
IList l = session.CreateQuery(
                 "SELECT pi.PATTERNTYPE, pi.PATTERNNAME " +
                 "FROM PATTERNINFO as pi")
                 .SetMaxResults(5)
                 .List();

works just fine, and returns 5 rows which are exactly what i want.

it seems like i just cannot concatenate them.
but according to the Section 11.8 Expressions of NHibernate documentation: "string concatenation || ".


Hibernate version:
1.2.1

Name and version of the database you are using:
MS SQL Server 2000

any more information should i provide?

thanks.

L.J.


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

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.