title: How to pass value to sqlRestriction of hibernate?
body: <p>I need to retrieve items based on a few different restrictions, one is to have code of 234 the other is to have calculated number of less than 10, but I am not sure how to pass values to the sqlRestrictions method.</p>
  
  <p>I am using {alias} but it passes Item rather than city to this.</p>
  
  <pre><code>List&lt;Store&gt; stores = (List&lt;Store&gt;) sessionFactory.getCurrentSession()
                  .createCriteria(Item.class)
                  .createAlias("Address", "address")
                  .createAlias("address.myJoinTable.city", "city")
                  .setProjection(pl)
                  .add(Restrictions.eq("address.myJoinTable.city",
                          session.load(City.class, myId)))
                  .add(Restrictions
                          .sqlRestriction("SELECT (
                                                   {alias}.id * {alias}.code * " 
                                                   + mynumber1 + " * " + mynumber2 + ") 
                                                    as number from city 
                                                    HAVING number &lt; 10")
                  .setResultTransformer(
                          new AliasToBeanResultTransformer(Store.class))
                  .list();
  </code></pre>