I run a query, where I count several sums on the different fields of same database entity. My problem arises when I am running tests on the query and at the same time changing the query from Mysql to the native language used on tests in IntelliJ Idea tool (I don’t know what it uses).
Problem is this: in the new environment all sum statements inside the single query return the value equal to the one that is got of the first sum statement.
I am using JPA and NativeQuery.
More information:
I have a code like this
List < Object [ ] > row = List < Object [ ] > em.createNativeQuery(“select sum (e.field), sum (e.otherField) from entity e where somevalue = something”).getResultList();
and then
return new MyResult ( ( Double ) row.get ( 0 ) [ 0 ] , ( Double )row.get ( 0 ) [ 1 ] );
Everything is inside a doInJPA function.
Real issue was identified to be so that my Idea used for testing HSQL and that somehow does not support
sumin the same way that Mysql does.