alias for expressions in hql queries <p>my Hibernate version is 3.2.6.ga</p> <p>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_ but how these are generated I don't know.</p> <p>For my case I want to add two derived columns into a third derived column. Trivial in native SQL, surprisingly difficult in HQL.</p> <p>My contrived, simplified example:</p> <pre><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 "; </code></pre> <p>How can I add the 2nd and 3rd columns together to form a 4th column in HQL?</p> <p>TIA,</p> <p>Still-learning Steve</p>