title: Using different projection functions in Hibernate criteria API based in Dialect
body: <p>I want to use a standard deviation projection in a query that Im constructing using the criteria API. I can do something simply like this</p>
  
  <pre><code>public class StdDevProjection extends AggregateProjection {
  
      public StdDevProjection(String propertyName) {
          super("stddev", propertyName);
      }
  
      public Type[] getTypes(Criteria criteria, CriteriaQuery criteriaQuery)
      throws HibernateException {
          return new Type[] { Hibernate.DOUBLE };
     }
  </code></pre>
  
  <p>}</p>
  
  <p>and then I can use it with my criteria as:                 </p>
  
  <pre><code>myCriteriea.setProjection(new StdDevProjection(myproperty));
  </code></pre>
  
  <p>Thats all good. But my problem is that I use HSQLDB for any db unit tests etc, whereas we use Oracle for deployment. The stddev function works perfectly in oracle, but its not there in HSQLDB. HSQLDB has stddev_pop and stddev_samp . So is there someway I can use a different function based on the dialect. </p>
  
  <p>I maybe can extend the HSQL dialect to register the "stddev" to the appropriate HSQL function, but then im not sure how to use an hsql function in a query constructed using the Criteria API.</p>
  
  <p>Any help would be gret.</p>
  
  <p>Thanks</p>