-->
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.  [ 4 posts ] 
Author Message
 Post subject: PROBLEM WITH AGGREGATE FUNCTION RETRIEVAL
PostPosted: Tue Oct 28, 2003 8:58 am 
Newbie

Joined: Tue Oct 28, 2003 8:49 am
Posts: 2
Location: INDIA
hi,
I'am a starter in the hibernate arena.
Please help in the following problem.
I'am facing a problem while using aggregate functions.
I'am using the example that is given in the documentation.



Query q = session.createQuery(
"select blog.name,count(blog) from eg.Blog as blog group by blog.name");

List l=q.list();
String b=(String)l.get(0);
System.out.println("count"+b);

here I'am facing a serious problem .
I'am getting class cast exception in this case.
I cannot cast the the object in the list to String or Integer.
What to do?

_________________
Nathan


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 28, 2003 9:00 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
What is returned is not a String, but an Object[], index 0 is a String, index 1 is an Integer.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 28, 2003 9:08 am 
Newbie

Joined: Tue Oct 28, 2003 8:49 am
Posts: 2
Location: INDIA
[quote="christian"]What is returned is not a String, but an Object[], index 0 is a String, index 1 is an Integer.[/quote]

It's not accepting an Object Array it's returning an object

_________________
Nathan


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 28, 2003 9:15 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
I'm sure it doesn't, it's an Object[].

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


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