my Hibernate version is 3.2.6.ga
Googling around reveals many people are having the same problems with Hibernate HQL not handling aliases very well. Apparently HQL only lets you alias a column that exists in a table. Also, HQL generates its own aliases for all columns in the query and these have the form col_x_y_. I've set my jdbc properties to show_sql=true to display the correct alias for the columns I wish to add,and tried these in my query, but even this doesn't work.
For my case I want to add two derived columns into a third derived column. Trivial in native SQL, surprisingly difficult in HQL.
My contrived, simplified example:
Code:
sqlcmd = " SELECT aa.course.code, " +
" (CASE WHEN aa.gender = 'M' THEN 1 ELSE 0 END), " +
" (CASE WHEN aa.gender = 'F' THEN 1 ELSE 0 END), " +
" ( col_0_1_ + col_0_2_ ) " +
" FROM Student AS aa ";
How can I add the 2nd and 3rd columns together to form a 4th column in HQL?
TIA,
Still-learning Steve