-->
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: select cat,count(*) from cat groupt by cat.type --> resul
PostPosted: Tue Jul 20, 2004 4:37 am 
Newbie

Joined: Wed May 12, 2004 3:17 pm
Posts: 11
dear all...

how to get the cat as Cat and the count of cats by giving the query as
"select cat,count(*) from cat groupt by cat.type" to the following function?
i am getting my function works fine. but i couldnt get the results wht i desired thru java codings...rather i dunno...!
am i right in defining the function which returns Collection for this case?
any tips on getting both the column as i desired will be much appreciated.

thanx in advance.

-NewBie(Still?!!!)

public Collection getCatsByQuery(String query){
Session session = ConnectionFactory
.getConnectionInstance().getSession();
Collection cats;
try
{
cats= session.find(query);
}catch ( HibernateException ex ){
ex.printStackTrace();
sfLogger.log( Level.SEVERE, "getCatsfailed", ex );
throw new RuntimeException( "getCatsfailed", ex );
}
finally
{
try
{
session.close();
}catch ( HibernateException ex ){
ex.printStackTrace();
sfLogger.log( Level.SEVERE, "closing session failed", ex );
throw new RuntimeException( "closing session failed", ex );
}
}
return cats;
}


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 21, 2004 3:08 am 
Newbie

Joined: Wed May 12, 2004 3:17 pm
Posts: 11
is it not possible to get a Class Object and a property by giving a single query to the sesstion.find() method which returns a Collection???


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 21, 2004 3:10 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
you have a Collection of object[] as said in the doc
object[1] is the count
object[0] is the cat
it is true for all the elements of your collection

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 21, 2004 8:25 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Do not crosspost

_________________
Emmanuel


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.