I know that this is probably a topic that has been hashed and rehashed, but searching these forums doesn't seem to turn anything up about "is null".
I'm wondering why queries still need to use "is null" instead of allowing null comparison with "=" which is converted behind the scenes into an "is null" query that's sent to the actual db.
If I do:
Code:
select * from com.ign.Foo where name=null
or if I do the following with :name bound to null:
Code:
select * from com.ign.Foo where name=:name
then why can't that be translated in the background to be
Code:
select * from FooTable where name is null
I understand tri-state logic and the reasons for having it in databases (specifically so that table joins work the way they do). I don't understand why we have to maintain that separation in the syntax of the query language. It just creates hassle and I have never understood what we gain by this.
As a result of these problems, I have in the past used a specific value to indicate null rather than using null itself so that I do not need to create one version of the query for each combination of is null. That's a completely ridiculous thing to have to do.
In other situations I've build the query with a ternary operator for each nullable field like
Code:
String query = "select * from FooTable where name"+ (name==null?" is null":("="+name))
Is there a reason for continuing to require "is null"? It just seems like madness to me.