java - How to get 2 fields concatenated in hibernate? -


say, i've table called "contact" "first_name" , "last_name" columns in it. basically, "select concat(c.firstname, ' ', c.lastname) fullname contact c" want in hibernate.

i can put entire query inside createquery , desired output. but, don't want execute sql queries in hibernate. found similar post here "can concatenate 2 properties in hibernate hql query?". executes sql query , of course has concat in clause(i want in select clause).

somebody please suggest answer.

you can introduce artificial field in entity , mark @formula annotation

e.g.

@formula("concat(first_name,' ',first_name)") private string fullname; 

see example here


Comments

Popular posts from this blog

jquery - How do you format the date used in the popover widget title of FullCalendar? -

Bubble Sort Manually a Linked List in Java -

asp.net mvc - SSO between MVCForum and Umbraco7 -