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)?
|