-->
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.  [ 4 posts ] 
Author Message
 Post subject: Can HQL do this?
PostPosted: Fri Dec 05, 2008 12:30 pm 
Newbie

Joined: Tue Aug 08, 2006 2:56 am
Posts: 6
Hello, I have a SQL with the append data to the column like this...

For example, table Student with a "name" column

I want make this SQL
Select 'Student:' + st.name from Student.

the result will be like this

2 records founded with one column
Student: Philip
Student: John

Can I make HQL to do this(I have a Student class with name property)

Please help me

Thank you....
Philip


Top
 Profile  
 
 Post subject: append query
PostPosted: Fri Dec 05, 2008 4:37 pm 
Beginner
Beginner

Joined: Fri May 16, 2008 3:59 pm
Posts: 30
Code:
Query q = session.createQuery("select from table where name= :name");
q.setString("name",value);
List list = q.list();


P.S. I need 1 credit so I can post again!


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 05, 2008 5:36 pm 
Regular
Regular

Joined: Mon Apr 19, 2004 6:54 pm
Posts: 79
Simply use the concat operator ||:

Code:
Select 'Student:' || st.name from Student


Christophe


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 05, 2008 8:38 pm 
Newbie

Joined: Tue Aug 08, 2006 2:56 am
Posts: 6
Thanks a lot, this is very helpful.

Philip


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.