title: Using IF construction in Hibernate
body: <p>I'm using the construction "if" in HSQL:</p>
  
  <pre><code>String q = "SELECT id, name, " +
                  "IF (ABS(name) &gt; 0, LPAD(ABS(name), 4, '0'), name) AS tord " +
                  "FROM table where city= " + cityId + " order by tord";
  
      Query query = session.createSQLQuery(q);
      List&lt;Object[]&gt; list = query.list();
      session.getTransaction().commit();
      session.close();
  </code></pre>
  
  <p>And now i want to refactor this piece of code with HQL. How can i do this?
  Thanks.</p>