Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
sushantk19
Creator
Creator

getting NULL pointer exception error in tmap

Hi,

 

I have flags logic as below:

 

(row6.paymentstate_id.equals(1)||row6.paymentstate_id.equals(6))&& row7.SKU.startsWith("DE-TB")?"Y":"N"
(row6.paymentstate_id.equals(1)||row6.paymentstate_id.equals(6))&& row7.SKU.startsWith("DE-PS")?"Y":"N"
(row6.paymentstate_id.equals(1)||row6.paymentstate_id.equals(6))&& row7.SKU.startsWith("DE-LB")?"Y":"N"

 

(row6.paymentstate_id.equals(1)||row6.paymentstate_id.equals(6))&&(row5.ordernumber!=null)?"Y":"N"

 

but because of these conditions i keep getting error

Exception in component tMap_1 (job_DM_000_Order)
java.lang.NullPointerException.

 

can you suggest why this is happenign and how do i handle this?

Labels (2)
1 Solution

Accepted Solutions
akumar2301
Specialist II
Specialist II

Hello

You need to handle null values or reverse your condition

“1”.equals(row...) || ....

General rule is to check null value before using it in any java expression

View solution in original post

3 Replies
akumar2301
Specialist II
Specialist II

Hello

You need to handle null values or reverse your condition

“1”.equals(row...) || ....

General rule is to check null value before using it in any java expression
Anonymous
Not applicable

Hello Sushant,

 

You have to handle null value when you are executing the job. Since equals, startwith are in built routine and whenever null value comes theses are not able to compare and throughs null pointer exception.
Try this it will work
(row6.paymentstate_id.equals("") || RELATIONAL.ISNULL(row6.paymentstate_id)) && (row7.SKU.equals("") || RELATIONAL.ISNULL(row7.SKU)) ? "" : (row6.paymentstate_id.equals(1)||row6.paymentstate_id.equals(6))&& row7.SKU.startsWith("DE-TB")?"Y":"N"

 

Thanks

sushantk19
Creator
Creator
Author

yes, that worked now. Actually I didnt handle NULL values first.