java.lang.NullPointerException when setting a 'null' value

One Star

java.lang.NullPointerException when setting a 'null' value

Hello,
I am faced with a 'java.lang.NullPointerException' when I set a null value in a (nullable) field a table of my database.
Here's the scenario:
An external source (my tFixedFlowInput in my example) can have a value and then change the value in base, or have no value, and in this case, I set the previous value to the base.
This works, except in the case I have no value in either the external source, or in the database (null and null). In this case, I have a 'java.lang.NullPointerException' on the line corresponding to the value of the field in the TMap:
temp_nva_out_tmp.isOK = !Relational.ISNULL(IN.isOK) ? 1 : temp_nva_in.isOK;

I do not understand how the assignment of the null can generate
'java.lang.NullPointerException'. If I replace temp_nva_in.isOK by 'null', it works correctly.
Thanks for ideas,
One Star

Re: java.lang.NullPointerException when setting a 'null' value

Hi
It's a rule that you can type null in expression. But if expression get null from a variable, it will cause NPE exception.
Regards,
Pedro
One Star

Re: java.lang.NullPointerException when setting a 'null' value

My expression is :
!Relational.ISNULL(in.isOK) ? 1 : temp_nva_in.isOK
is the Tmap.
In the java code :
// # Output table : 'temp_nva_out'
temp_nva_out_tmp.uid = in.uid;
temp_nva_out_tmp.isOK = !Relational.ISNULL(in.isOK) ? 1 : temp_nva_in.isOK;
temp_nva_out = temp_nva_out_tmp;
One Star

Re: java.lang.NullPointerException when setting a 'null' value

Hi
It seems that there are null values in temp_nva_in.isOK.
You can put a tJavaRow between the input component and tMap and type code as follow.
if(input_row.isOk==null)
output_row.isOk = 0;

Regards,
Pedro
One Star

Re: java.lang.NullPointerException when setting a 'null' value

Thanks,
But I'd like to keep my 'null' value. I don't want to set '0' if it's 'null'.
One Star

Re: java.lang.NullPointerException when setting a 'null' value

temp_nva_out_tmp.isOK = !Relational.ISNULL(in.isOK) ? new Integer( 1 ) : temp_nva_in.isOK;

works and
temp_nva_out_tmp.isOK = !Relational.ISNULL(in.isOK) ? 1 : temp_nva_in.isOK;

doesn't work.
I don't understand why. Thanks if you could explain me?