-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: SELECT new myClass(...) fails in 3.2.2
PostPosted: Wed Mar 07, 2007 9:02 am 
Newbie

Joined: Tue Feb 28, 2006 5:03 pm
Posts: 15
Location: North Carolina
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:


Top
 Profile  
 
 Post subject: COUNT yields a different data type
PostPosted: Wed Mar 07, 2007 9:41 am 
Newbie

Joined: Tue Feb 28, 2006 5:03 pm
Posts: 15
Location: North Carolina
In 3.1.3, SELECT COUNT(xx) will return a java.lang.Integer, but in 3.2.2 it will return a java.lang.Long. So, my constructor that used a Integer was not valid. Once I change the constructor (or add another one), everything works fine.

Thanks and keep up the good work


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.