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: how to create below query in HQL
PostPosted: Fri Nov 21, 2008 2:55 am 
Newbie

Joined: Mon Sep 08, 2008 2:37 am
Posts: 6
Hi,

i want to concatinate and get data from DB using hql

i want to get the relavent query for the below sql query

Code:
select  e.*,(e.firstname||' '|| e.middlename || ' '|| e.lastname) as EMPNAME from employees e


any help is greatly appreciated

_________________
loknath


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 24, 2008 4:14 am 
Expert
Expert

Joined: Thu Dec 14, 2006 5:57 am
Posts: 1185
Location: Zurich, Switzerland
Have you tried:

select e, (e.FirstName ||' '|| e.MiddleName || ' '|| e.LastName) from employees e

You then should get an array with to elements {instance of e, concatenated name}.

But I suggest one of these approaches instead:

1) you use a "calculated" property in the mapping: formula="firstname || middlename || lastname"

2) you define a property on your employee class that does that in the getter.

_________________
--Wolfgang


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.