-->
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: Maxm, avg and Min function
PostPosted: Tue Aug 03, 2010 11:23 am 
Newbie

Joined: Wed Sep 09, 2009 4:15 am
Posts: 14
Hello, I have this HQL:
Code:
select max(stat.durataelaborazione/stat.numeropagine), avg(stat.durataelaborazione/stat.numeropagine), min(stat.durataelaborazione/stat.numeropagine)...


But I get a Long, Double, Long object, why? A division between long can be a double! How can i change this behaviour?

Thanks.


Top
 Profile  
 
 Post subject: Re: Maxm, avg and Min function
PostPosted: Wed Aug 04, 2010 4:03 am 
Newbie

Joined: Wed Sep 09, 2009 4:15 am
Posts: 14
Nobody can help me, please?


Top
 Profile  
 
 Post subject: Re: Maxm, avg and Min function
PostPosted: Wed Aug 04, 2010 6:08 am 
Newbie

Joined: Wed Sep 09, 2009 4:15 am
Posts: 14
What do you mean? I know this, but i think i have a trouble with hibernate not with Oracle.

I have two Long fields, if my HQL is:
Code:
select max(Field/Filed2)
I expect a Double value, not a Long like for a simple max(Filed)


Top
 Profile  
 
 Post subject: Re: Maxm, avg and Min function
PostPosted: Wed Aug 04, 2010 9:01 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Quote:
What do you mean?
sorry, that was spam and I removed it.

Quote:
But I get a Long, Double, Long object, why? A division between long can be a double! How can i change this behaviour?

I'm not sure how you can change that. did you try using casts in the hql? or you could use a resulttransformet, or define a value object for the query and have something like:
Code:
select new Dto(max(stat.durataelaborazione/stat.numeropagine), avg(stat.durataelaborazione/stat.numeropagine), min(stat.durataelaborazione/stat.numeropagine)) ...


(provided you create a Dto having the appropriate constructors; that's what I usually do as I prefer to deal with objects with properties than with arrays of things of different types.)

_________________
Sanne
http://in.relation.to/


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.