This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Object Relational Mapping and the fly likes Use alias in query Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Use alias in query" Watch "Use alias in query" New topic
Author

Use alias in query

fabian verbeek
Ranch Hand

Joined: Oct 20, 2012
Posts: 52
Hi,

I'm new in hibernate and i would like concat 2 fields and put in an alias
like this i mysql:

SELECT CONCAT(a,b) AS c from table ORDER BY CONCAT(a,b)

How can i use this in the query hibernate

Query q = session.createQuery("FROM table order by ?");

thanks for your help
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Use alias in query
 
Similar Threads
concatination of 3 fields in SQL query
HQL query problem
named sql-query dilema
escaping SQL keywords in hibernate
query returning null