-->
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.  [ 3 posts ] 
Author Message
 Post subject: Sorry, stupid question
PostPosted: Thu May 05, 2005 8:38 am 
Regular
Regular

Joined: Thu Feb 24, 2005 2:34 pm
Posts: 80
Hibernate version:3rc

Sorry for this question, but i don't understand one thing.
if you can look my code, i can't use "aggregation hql" and to cast into my object[]?, because i think, Hibenernate not know the set/get method for "sum(ay.qtavdi)";

There is a method for to do aggregation without hql and to use my Object, how for example "select"?

I hope to write correct my question, can you help me?
Devis

Quote:
public CVenditaVO[] Categoria(String shop,String data)
{

try {


if(data.length()==10)
{
String aa = data.substring(6, 10);
String mm = data.substring(3, 5);
String gg = data.substring(0, 2);

data=aa+"-"+mm+"-"+gg;
}


Session session = AS400Session.currentSession();
Query sql = session.createQuery(
"Select ay.modevo.cdc_cmpf,ay.modevo.dsc_cmpf,sum(ay.qtavdi) from CVenditaVO as ay where ay.pk.shopdi=? and ay.pk.datadi=? Group by ay.modevo.cdc_cmpf,ay.modevo.dsc_cmpf");
sql.setString(0, shop);
sql.setDate(1, java.sql.Date.valueOf(data));

ArrayList list = new ArrayList();
list = (ArrayList) sql.list();
CVenditaVO vos[] = new CVenditaVO[list.size()];
list.toArray(vos);
session.connection().commit();
AS400Session.closeSession();
return vos;
}
catch (Exception ex) {
AS400Session.RollBack();
log.fatal(ex.getMessage());
throw new java.lang.UnsupportedOperationException(
"Method selectReso " + ex.getMessage());
}
finally {

AS400Session.closeSession();
}


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 05, 2005 10:02 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
what do you want to do exactly? retrieve sum(ay.qtavdi)??

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


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 05, 2005 10:14 am 
Regular
Regular

Joined: Thu Feb 24, 2005 2:34 pm
Posts: 80
Hi, yes
i have an object, i wish that this object been group by the same "modedi"
and sum(ay.qtavdi)??
I'm test "criteria" seems very powerful, but i don't find
using createCriteria with aggregate function "sum".
Can you help me
Devis


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.