-->
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: Dynamic instantiation with count(*)
PostPosted: Fri Nov 30, 2007 9:59 pm 
Newbie

Joined: Fri May 25, 2007 2:09 pm
Posts: 6
When using dynamic instantiation, does each property in the data-transfer have to equate to a column?

Goal: Count an item's bids by bidder
HQL: select new BidSummary ( item.bidder , count(*) ) from Item item where ...
BidSummary class has contructor BidSummary(Bidder bidder, int bids)


With this I get an error "unable to locate appropriate constructor on class [BidSummary]


As a test, I changed the count(*) to an integer column and that works, though not the results I wanted. ;-)


So far none of the examples (Hibernate in Action book, this forum, google) I've come across use an aggregate function. :-(

Thanks!


Top
 Profile  
 
 Post subject: Answer's in the book
PostPosted: Mon Dec 03, 2007 1:46 pm 
Newbie

Joined: Fri May 25, 2007 2:09 pm
Posts: 6
Actually, the book has an example using count() and avg() in section 7.4.4 Restricting groups with having.

The fix is in the BidSummary constructor (just like the error suggested ;-).
I had BidSummary(Bidder, Integer).
It should've been BidSummary(Bidder, Long).


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.