-->
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.  [ 12 posts ] 
Author Message
 Post subject: HQL "select count(*)" returns Long?
PostPosted: Sat Jul 08, 2006 2:44 pm 
Newbie

Joined: Fri Feb 17, 2006 12:18 am
Posts: 11
hi, i'm using hibernate 3.2 RC2, and i found a very strange problem:

when i try to use hql:

"select count(*) from..."

Code:
int count = ((Integer)query.uniqueResult()).intValue;


it report a ClassCastException, and after trace i found the real type returned by "select count(*)" is Long!!!

is it caused by HSQLDialect? For these codes works well in hibernate 3.1.2 and SQLDialect.

thanks![/b]


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jul 08, 2006 4:28 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
if you read the migration guide and change log you would now the answer.

This was needed to be JPA compliant. see the migration guide on our wiki.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jul 08, 2006 4:50 pm 
Newbie

Joined: Fri Feb 17, 2006 12:18 am
Posts: 11
Thx! and i found out how to make my code works:
Code:
  Configuration classicCfg = new Configuration();
  classicCfg.addSqlFunction( "count", new ClassicCountFunction());
  classicCfg.addSqlFunction( "avg", new ClassicAvgFunction());
  classicCfg.addSqlFunction( "sum", new ClassicSumFunction());
  SessionFactory classicSf = classicCfg.buildSessionFactory();


Top
 Profile  
 
 Post subject: Not working
PostPosted: Mon Aug 28, 2006 4:53 pm 
Newbie

Joined: Mon Aug 28, 2006 4:43 pm
Posts: 6
I tried do

Configuration classicCfg = new Configuration();
classicCfg.addSqlFunction( "count", new ClassicCountFunction());


but the class org.hibernate.cfg.Configuration do not have the method addSqlFunction.

What i wrong?

_________________
The Quest Maker


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 28, 2006 5:02 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
you are not using a recent release of hibernate 3.2.x

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 29, 2006 7:32 am 
Newbie

Joined: Mon Aug 28, 2006 4:43 pm
Posts: 6
But i am using the version 3.2.0-cr2

_________________
The Quest Maker


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 29, 2006 7:33 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
the latest release is -cr4

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 29, 2006 7:40 am 
Newbie

Joined: Mon Aug 28, 2006 4:43 pm
Posts: 6
OK, tks for the help. But in the web site the is no link to get cr4, but if you write in the url to get cr2 and jsut change cr2 to cr4 its works. :)

tks once more.

_________________
The Quest Maker


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 29, 2006 7:41 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
what part of the webpage are you looking at ?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 29, 2006 7:43 am 
Newbie

Joined: Mon Aug 28, 2006 4:43 pm
Posts: 6
This page http://hibernate.org/6.html, in the download area.

_________________
The Quest Maker


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 29, 2006 7:48 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
ah - fixed. thanks.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 29, 2006 7:53 am 
Newbie

Joined: Mon Aug 28, 2006 4:43 pm
Posts: 6
Ok :)

_________________
The Quest Maker


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 12 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.