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;
}
|