-->
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: String concatenation
PostPosted: Mon Feb 20, 2006 6:49 am 
Newbie

Joined: Mon Feb 20, 2006 6:31 am
Posts: 17
I have a simple problem, but I can't find the solution.
I have a database table Driver that contains the columns FirstName and LastName (and lost of other columns). I have a corresponding object Driver with properties FirstName and LastName. My user requirements ask me to search for a user using 'Lastname Firstname'. How can I do this? Since names can contain spaces in both Firstname and Lastname, there is no way for me to determine where the lastname ends and the firstname begins. In SQL I would use
Code:
SELECT * FROM DRIVER
WHERE NameEntered = Lastname || ' ' || Firstname

When I try this in NHibernate, I get the following exception: undefined alias or unknown mapping: NHibernateTest [from NHibernateTest.Driver dr where :Name = dr.LastName || ' ' || dr.FirstName].

Can anyone point me towards a solution for this?
Thanks
Peter


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 20, 2006 10:14 am 
Newbie

Joined: Mon Feb 20, 2006 6:31 am
Posts: 17
Apparently this seems to work in HQL:
" from Driver where LastName || ' ' || FirstName = 'The builder Bob' "
I think the solution didn't work the first times because a dll file containing my mappings and object model was not correctly refreshed. No mappings worked any more...


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.