Five Stars

null pointer exception

Hi experts,

I'm facing null pointer exception in Tmap when I'm doing calculation below you can see in screen shot,

and I already checked in database for same calculation but their are no null values in them how to resolve this error

 

Thanks in advance 

Regards

A.Sumanthcap1.PNGCap2.PNGCap3.PNGcap9.PNG

8 REPLIES
Employee

Re: null pointer exception

Are you sure it is row18 or row1 the object?

Five Stars

Re: null pointer exception

Ya sure it is row18
Five Stars

Re: null pointer exception

Ya it's row18
Tags (1)
Employee

Re: null pointer exception

Please provide screenshots of your job and tMap mapping.  Not sure what it is.

Five Stars

Re: null pointer exception

Ca1.PNGCa2.PNGCa3.PNG

Ten Stars

Re: null pointer exception

Community all-star, @rhall_2_0, wrote a very nice guide on how to identify which rows are causing errors in a tMap:

https://www.rilhia.com/quicktips/quick-tip-how-debug-tmap-errors

 

If this works for you, throw him some kudos.

Employee

Re: null pointer exception

If row18.CUST_TOTAL_QUOTA_BEFORE and row18.CUST_TOTAL_QUOTA_USED_BEFORE are both Java Objects of type Double (i.e. they are set as nullable), and are not Java primitive type double,  then you should do the expression as follows

 

row18.CUST_TOTAL_QUOTA_BEFORE!=null && row18.CUST_TOTAL_QUOTA_USED_BEFORE!=null ? new Double(row18.CUST_TOTAL_QUOTA_BEFORE.doubleValue() - row18.CUST_TOTAL_QUOTA_USED_BEFORE.doubleValue()) : null)

 

This is an inline if statement.  We are checking first that none of the 2 objects are null. Then if both are not null, we do the double substraction, and return a new Double object since your target column is also of type Double.  If one or both of the Double objects are null, then we return null.  It is up to you to figure out what to do if one of them is null.

 

If these values can never be null in the database, then you will simplify the logic by unchecking the nullable attribute on the column to make the type of double Java primitive type.  However, if they can be null, then you should program as above, i.e. defensively checking for nulls.

 

Five Stars

Re: null pointer exception

Thank you so much expert,I was struggling with this problem from past ten days you are the one who gave me correct

solution from my question,By understanding the question properly

I need the expert like you for solutions thank you once again it's working fine 

Regards

A.Sumanth