You are not logged in.
Announcement
Unanswered posts
|
Pages: 1

Hi
I'm trying to make a filter on my table prt_adh on the value prt_cat. I xant it to be equals to "A"
So here is what i put on the filter:
prt_adh.PRT_CAT.equals("A")
But when this value is null, i've got a Null pointer exception.
My fileds is nullable, so I'm telling myself let's make a condition that don't take null value in the filter, with this code:
(null != prt_adh.PRT_CAT)?prt_adh.PRT_CAT.equals("A") : null
And then the message error is that he's Expecting to find integer on stack
I don't know how to do now.
Thanks for your help !
Offline

For your information I'm using TMap component.
And now I tried to make the filter directly on the SQL command on the prt table
That is to say on the request SELECT .... FROM PRT WHERE PRT.PRT_CAT='A'"
And with this filter it works, so is the TMap filter bugged or did I miss something ??
Thanks for your help !
Offline
Benoit,
Your solution will work well, but this info may also be helpful in other scenarios:
Generally when using .equals() it is safer to put the constant first, as in "A".equals(prt_adh.PRT_CAT). Because "A" will always be a string, you can always use the .equals() method on it. If you use prt_adh.PRT_CAT.equals("A"), prt_adh.PRT_CAT may be null, and the null data type has no .equals() method, which is what was causing your problem.
Thanks,
Ben
Offline

Thanks for your answer, indeed I have no longer this problem of NPE but still I've got the result I want with my solution but not with yours.
Could you tell me why i don't have the same result ?
Thanks for your help !
Offline
Pages: 1