I have the following problem trying to store the correct output of this SQL query into a double variable into a Java applcation.
So I have this SQL query:
SELECT sum(anagraficaEdificio.imp_tot_ind - anagraficaEdificio.imp_cof) FROM TID003_ANAGEDIFICIO anagraficaEdificio
INNER JOIN TID002_CANDIDATURA candidatura ON (candidatura.PRG_PAR = anagraficaEdificio.PRG_PAR AND candidatura.PRG_CAN = anagraficaEdificio.PRG_CAN)
INNER JOIN TID001_ANAGPARTECIPA anagPartecipa ON(anagPartecipa.PRG_PAR = candidatura.PRG_PAR)
INNER JOIN anagrafiche.TPG1029_PROVNUOIST provNuovIst ON (provNuovIst.COD_PRV_NIS = anagPartecipa.COD_PRV_NIS)
WHERE FLG_GRA=1
Performing this query directly on my database (using its client) I obtain this correct numeric result: 36481888,47
Ok, so I have implemented it into a Java application (using SpringDataJpa, but I think that this is not important, because it is performed as SQL native query) by:
@Query(value = "SELECT sum(anagraficaEdificio.imp_tot_ind - anagraficaEdificio.imp_cof) FROM TID003_ANAGEDIFICIO anagraficaEdificio "
+ "INNER JOIN TID002_CANDIDATURA candidatura ON (candidatura.PRG_PAR = anagraficaEdificio.PRG_PAR AND candidatura.PRG_CAN = anagraficaEdificio.PRG_CAN) "
+ "INNER JOIN TID001_ANAGPARTECIPA anagPartecipa ON(anagPartecipa.PRG_PAR = candidatura.PRG_PAR) "
+ "INNER JOIN anagrafiche.TPG1029_PROVNUOIST provNuovIst ON (provNuovIst.COD_PRV_NIS = anagPartecipa.COD_PRV_NIS) "
+ "WHERE FLG_GRA=1", nativeQuery = true)
double getImportoFinanziabileNazionale();
that perform the original query.
The problem is that when I call this method by:
double risultato = tid003AnagedificioRepository.getImportoFinanziabileMiurNazionale();
the value stored into the risultato variable is not 36481888,47 (the correct one) but I obtain this value 3.648188847E7.
Why it contains an E inside it? Is something related to an exponensial notation or something like this? How can I obtain the oringial 36481888,47 value returned by my query into my Java application? Is it related to the use of double?
What am I missing? How can I fix this issue?