title: What is Hibernate equivalent of Projections.Cast?
body: <p>I have fixed my problem using HQL and it is working great. </p>
  
  <p>But I do like Criteria API. (I have a few ifs statements in my querybuilder string for HQL, yuck) 
  Apparently Projections.sum(property) return double. </p>
  
  <p>My Entity class has </p>
  
  <pre><code>@Column(name = "current_volume")   
  private Integer currentVolume;
  </code></pre>
  
  <p>The error I get is </p>
  
  <blockquote>
    <p>org.hibernate.PropertyAccessException: IllegalArgumentException occurred while calling setter of se.unox.pejl.entity.value.pejl.PejlDataTrendValue.currentVolume.</p>
  </blockquote>
  
  <p>My equivalent working hql is </p>
  
  <pre><code>select cast(sum(p.currentVolume/1000) as integer) as currentVolume from      
  se.unox.pejl.entity.value.pejl.PejlDataTrendValue as p
  </code></pre>
  
  <p>I think I know what the problem is, but cannot figure out how to cast sum of columns (which is INT(11) in mysql) into Integer. Apparently NHibernate has Projections.Cast</p>
  
  <p>I am using Hibernate 3.6</p>