Issue
Lets say I have one table with two columns firstname
and lastname
with String datatype. Normally I write my hql query like
"select firstname,lastname from contact"
Can I write a hql query which concatenates both property ?
Maybe something like "select firstname+lastname as fullname from Contact"
Solution
select concat(c.firstname, c.lastname) as fullname from Contact c
or, if you want a separator:
select concat(c.firstname, ' ', c.lastname) as fullname from Contact c
See the documentation.
Answered By - JB Nizet
Answer Checked By - David Goodson (JavaFixing Volunteer)