title: JPA/Hibernate + HQL/JPQL: select DTO with BigDecimal parameter
body: <p>We are using JPA with hibernate as the implementation. Suppose I have the following DTO:</p>
  
  <pre><code>public class SupplierInfoDto{
     private String supplierName;
     private BigDecimal remainingFinances;
  
     public SupplierInfoDto(String supplierName, BigDecimal remainingFinances){
         this.supplierName = supplierName;
         this.remainingFinances = remainingFinances;
     }
  
     // getters / setters
  }
  </code></pre>
  
  <p>I cannot seem to get hibernate to properly find this constructor. I first tried the following query (the model is more complicated than this, and I need to fetch some aggregations eventually (not directly on the entities), that's why I'm fetching a DTO instead of the entities):</p>
  
  <pre><code>SELECT NEW com.company.dto.SupplierInfoDto(s.name, f.remaining)
  FROM Supplier s INNER JOIN Finances f
  WHERE s.id = :SupplierId
  </code></pre>
  
  <p>However, I get a  <code>org.hibernate.hql.ast.QuerySyntaxException: Unable to locate appropriate constructor on class</code> exception. </p>
  
  <p>The <code>remaining</code> column I'm selecting from is stored as a float in MSSQL (I know, I know money should never be stored as floats, but this is an existing system where I cannot just change this datatype)..</p>
  
  <p>As a test, I tried the following query, but with the same exception as above:</p>
  
  <pre><code>SELECT NEW com.company.dto.SupplierInfoDto(s.name, NEW java.math.BigDecimal(10))
  FROM Supplier s
  WHERE s.id = :SupplierId
  </code></pre>
  
  <p>So my question is: How do I make hibernate/JPA find the appropriate constructor for the two queries above?</p>
  
  <p><strong>UPDATE:</strong> The <code>remaining</code> property is of type double on the Finances entity (not my decision).</p>