BestJewSinceJC
Posting Maven
2,772 posts since Sep 2008
Reputation Points: 874
Solved Threads: 354
[QUOTE=cesarnz;939193
...and why does it work if i declare a local variable and assign it the same value as before ??
.[/QUOTE]
Hi
When you assign a local variable the value of the object and ask for a comparison to 0 whit the operator == the two values are compared.
When you ask for the same thing to be done whit the object, and uses the operator == what you compare is not the value of the object but the objects referents (address) compared to 0.
If you want the value in the object to be compared to 0 then you have to use the method equals() instead of the == operator.
Hope this will give some help.
Good luck =)
sneaker
Junior Poster in Training
77 posts since Jul 2009
Reputation Points: 40
Solved Threads: 13
>any help to understand how/why the above works would be much
>appreciated.
The problem you are facing could be very well because of a broken library implementation.
From what I can make out of the stacktrace, the implementation blows up when trying to convert the value of your object field i.e. ID to a primitive. Also given that it *works* when you add a zero to the ID field, I guess that there is some kind of implicit coercion taking place which makes the entire comparison *work* somehow.
Again, this is all guesswork and would be best answered on the forum for that given third party library. You can try printing out the value of "tmpID" in the second case; what does it give? NaN? Does printing out the value "dbObject.ID" cause the same stackoverflow issue?
~s.o.s~
Failure as a human
11,938 posts since Jun 2006
Reputation Points: 3,281
Solved Threads: 734