-->
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: Does count query return long instead of int in v3.2?
PostPosted: Thu Oct 26, 2006 6:38 pm 
Newbie

Joined: Wed Sep 20, 2006 2:57 pm
Posts: 16
Location: Encinitas, CA
Sorry if this is an old topic. I checked the Hibernate 3.2 migration guide and did some searching, but couldn't find anything.

Using Hibernate 3.1.1, we have some Java code that does a simple count aggregation query to get a quantity of records. We cast the result to an Integer and return it.

I just downloaded and tried 3.2 in the hopes that it would solve my problem of not being able to get FULL JOINS to work under any circumstances. I routinely do LEFT and RIGHT joins across multiple tables, so I thought I knew what I was doing. My database is PostgreSQL 8.0.3 and I can do FULL joins in its query tool just fine.

Please, no one send me links to the reference documentation section 14.3 that claims Hibernate does full joins. Been there a billion times.

So with 3.1.1 the code below worked but with 3.2 we get a ClassCastException. Is that a surprise to anyone, or does it simply mean count queries now return long instead of int?
(which makes a lot sense when you think about it)

Code:
List x = session.createQuery("SELECT count(j) ...query text omitted...").list();
Integer i = (Integer) x.get(0);


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 27, 2006 8:50 am 
Senior
Senior

Joined: Wed Aug 17, 2005 12:56 pm
Posts: 136
Location: Erie, PA (USA)
According the migration guide (http://www.hibernate.org/250.html), there are changes to return types for aggregate functions. It refers you to a JIRI page (http://opensource.atlassian.com/projects/hibernate/browse/HHH-1538) that states that the return type for SUM is now long.

Curtis ...

_________________
---- Don't forget to rate! ----


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.