Hello folks,

I was wondering why when I was fetching a sql select sentence (inside RowMapper prodecude inside jdbcTemplate ), the condition I set for avoid null exception didn't work.

I mean, when having if sentence like:

Java Code:
rs.getTimestamp("bornDate")
why the condition worked as follows:

Java Code:
if (rs.getTimestamp("bornDate") == null )
and not
Java Code:
if (rs.getTimestamp("bornDate").equals(null) )
instead.

While debugging, condition was always false with equals even if the result set got null value. Changing it by == worked like a charm.

¿Isn't supposed while comparing objects we should use equals instead of == ?.

I can understand the reference of resultset will not be null, but the value itself instead which is what I was searching for (in order to do the if sentence).

I am confused

Some advice will be helpful , thanks.