I calculate the sum of to variable getting from 2 request, the result is recovered but when I want to exploit it an NullPointerException is thrown:
public List<Object[]> buildQuery4SConsistencyCheck(Societe societe,ParamSociete paramSociete,Date
periode) throws TechnicalNGEException {
String sql="select SUM(INTERNAL_AMOUNT) from (select vR.montant_valorise as INTERNAL_AMOUNT"
+ " from sigma02.valorisation_location vR inner join sigma02.eds soc on
vR.societe=soc.id_eds "
+ "inner join sigma02.chantier ch on vR.compte_de_recette=ch.id_eds"
+ " inner join sigma02.edsm on vR.id_edsm=edsm.id_edsm inner join sigma02.eds "
+ "edsR on vR.compte_de_recette=edsR.id_eds where vR.montant_facture !=0 and
vR.statut_traitment "
+ "like 'F' and vR.societe = 11 and vR.date_piece='2018-1-31' union all select "
+ " vDep.montant_valorise as INTERNAL_AMOUNT FROM sigma02.valorisation_location"
+ " vDep inner join sigma02.eds soc on vDep.societe=soc.id_eds "
+ "inner join sigma02.eds as edsDep on vDep.chantier_materiel=edsDep.id_eds "
+ "inner join sigma02.chantier as chDep on vDep.chantier_materiel=chDep.id_eds"
+ " inner join sigma02.edsm on vDep.id_edsm=edsm.id_edsm WHERE vDep.montant_facture<>0"
+ " and vDep.statut_traitment='F' and vDep.societe=11 and vDep.date_piece='2018-1-31' )
as somme";
List<Object[]> result = null;
try {
SQLQuery query = session.createSQLQuery(sql);
result = query.list();
} catch (HibernateException e) {
bloqException(e);
}
return result;
}
in this line where the exception is thrown:
@Autowired
private ValorisationLocationDAO valorisationLocationDAO;
Object[] c=
valorisationLocationDAO.buildQuery4SConsistencyCheck(societe,paramSociete,periode).get(0);
After debbuggin I get this in result:
[93648.40, null, null, null, null, null, null, null, null, null]
this is the error :
Caused by: java.lang.NullPointerException
at com.nge.sigma.reprise.util.BatchLogger.log(BatchLogger.java:205) [sigma-
reprise-0.0.14-SNAPSHOT.jar:]
at com.nge.sigma.reprise.util.BatchLogger.logDebug(BatchLogger.java:193)
[sigma-reprise-0.0.14-SNAPSHOT.jar:]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.8.0_221]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) [rt.jar:1.8.0_221]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) [rt.jar:1.8.0_221]
at java.lang.reflect.Method.invoke(Unknown Source) [rt.jar:1.8.0_221]
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317) [spring-aop-4.0.5.RELEASE.jar:4.0.5.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190) [spring-aop-4.0.5.RELEASE.jar:4.0.5.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157) [spring-aop-4.0.5.RELEASE.jar:4.0.5.RELEASE]
at org.springframework.aop.framework.adapter.MethodBeforeAdviceInterceptor.invoke(MethodBeforeAdviceInterceptor.java:52) [spring-aop-4.0.5.RELEASE.jar:4.0.5.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) [spring-aop-4.0.5.RELEASE.jar:4.0.5.RELEASE]
at org.springframework.aop.framework.adapter.AfterReturningAdviceInterceptor.invoke(AfterReturningAdviceInterceptor.java:52) [spring-aop-4.0.5.RELEASE.jar:4.0.5.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) [spring-aop-4.0.5.RELEASE.jar:4.0.5.RELEASE]
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92) [spring-aop-4.0.5.RELEASE.jar:4.0.5.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) [spring-aop-4.0.5.RELEASE.jar:4.0.5.RELEASE]
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207) [spring-aop-4.0.5.RELEASE.jar:4.0.5.RELEASE]
at com.sun.proxy.$Proxy447.logDebug(Unknown Source)