I don't know if this is intended behaviour or not, but I just spent some time debugging this.
If you execute a native query using hibernate, and the resulting column names are identical, all your columns will have the same result.
Take the following example query.
select * from ( select count(distinct tr.id) from <…> where <…>) as t0 join ( select count(distinct tr.id) from <…> where <…>) as t1 join ( select count(distinct tr.id) from <…> where <…>) as t2 join ( select count(distinct tr.id) from <…> where <…>) as t3
MySQL yields
count(distinct tr.id) count(distinct tr.id) count(distinct tr.id) count(distinct tr.id) 122 111 239 208
Hibernate result yields an Object[] = {122,122,122,122};
select * from ( select count(distinct tr.id) as col0 from <…> where <…>) as t0 join ( select count(distinct tr.id) as col1 from <…> where <…>) as t1 join ( select count(distinct tr.id) as col2 from <…> where <…>) as t2 join ( select count(distinct tr.id) as col3 from <…> where <…>) as t3 MySQL yields
col0 col1 col2 col3 122 111 239 208
And Hibernate yields the correct result Object[] = {122,111,239,208}
|