I was using the following code in 3.1.3:
Code:
session.createQuery("SELECT new SummaryInfo(COUNT(f.loanKey.loanNumber), SUM(f.loanAmount)) ...");
In 3.1.3, this code works correctly. With no other code changes, if I use the 3.2.2 (or 3.2.1 or 3.2.0) jar, I get the following exception when I try to create the Query. Does hibernate no longer support creating a domain object directly from a query? Or is this a bug? Or (more likely) am I using this incorrectly?
[cause=org.hibernate.PropertyNotFoundException: no appropriate constructor in class: com.bofa.loancity.value.SummaryInfo]
Exception in thread "Main Thread" org.hibernate.hql.ast.QuerySyntaxException: Unable to locate appropriate constructor on class [com.bofa.loancity.value.SummaryInfo] [SELECT new com.bofa.loancity.value.SummaryInfo(COUNT(f.loanKey.loanNumber), SUM(f.loanAmount), SUM(f.fundingPlusAccrued), SUM(f.loanAmount * f.interestRate) / SUM(f.loanAmount), SUM(f.loanAmount * f.takeOutPrice) / SUM(f.loanAmount)) FROM com.bofa.loancity.value.Funding AS f WHERE f.loanStatus = :active AND f.loanKey.settleDate >= :split]
at org.hibernate.hql.ast.QuerySyntaxException.convert(QuerySyntaxException.java:31)
at org.hibernate.hql.ast.QuerySyntaxException.convert(QuerySyntaxException.java:24)
at org.hibernate.hql.ast.ErrorCounter.throwQueryException(ErrorCounter.java:59)
at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:235)
at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:160)
at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:111)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:77)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:56)
at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:72)
at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:133)
at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:112)
at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1623)
at com.bofa.loancity.biz.SummaryBiz.CollectSummaryInformationAfter(SummaryBiz.java:523)
at com.bofa.loancity.util.reports.SummaryPage.retrieveSummaryInfo(SummaryPage.java:301)
at com.bofa.loancity.util.reports.SummaryPage.main(SummaryPage.java:416)
Code: