-->
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.  [ 1 post ] 
Author Message
 Post subject: strange behavior
PostPosted: Wed May 22, 2013 7:47 am 
Newbie

Joined: Wed May 22, 2013 7:03 am
Posts: 1
Hi, everyone.

I have got strange results of using Hibernate.
I am launching next code:

Session session = HibernateUtil.getSessionFactory().getCurrentSession();
session.beginTransaction();
List<Object[]> result = session.createSQLQuery("SELECT EXTRACT(DAY FROM d),SUM(time00),SUM(time01) FROM fact GROUP BY d ORDER BY d").list();
session.getTransaction().commit();
for (int i = 0; i < result.size(); i++) {
for (int j = 0; j < result.get(i).length; j++)
System.out.print(result.get(i)[j].toString() + " ");
System.out.println();
}


the results are next
1.0 2634868 2634868
2.0 2520685 2520685
3.0 2555712 2555712
......

second and third column are the same and they correspond to the SUM(time00)

if I change the positions of SUM(time00) and SUM(time01) in the script the results will be next
1.0 2544291 2544291
2.0 2370202 2370202
3.0 2379230 2379230
...
But the results must be
1.0 2634868 2544291
2.0 2520685 2370202
3.0 2555712 2379230

If I run next one:
List<Object[]> result = session.createSQLQuery("SELECT SUM(time01),EXTRACT(DAY FROM d),SUM(time00) FROM fact GROUP BY d ORDER BY d").list();
I will have
2544291 1.0 2544291
2370202 2.0 2370202
2379230 3.0 2379230

This SQL scripte is correct and everything working right when I use pgAdmin or jdbc.
Does anybody know the resone why the query retenre the same colums for SUM(time00) and SUM(time01)?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.