db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Geoff Fortytwo <...@ign.com>
Subject Why? Criteria.ISNULL (or SqlEnum.ISNULL)
Date Thu, 23 Oct 2003 23:54:56 GMT
I just struggled through figuring out how to add an "IS NULL" comparison to 
a Criteria. It was much more difficult than it should be.

My first attempt (the column is called "KEY2"):
   crit.add(KEY2,null)
this gave an "ORA-00936: missing expression" exception. The actual sql it 
output when I did a crit.toString() had the following in the WHERE clause:
   usersGameStatList.KEY2 IS NULL
so I can't imagine why it didn't work.

In any case, I then tried:
   crit.add(KEY2,null,Criteria.ISNULL);
that also failed because it put the following in the query:
   usersGameStatList.KEY2= IS NULL

I then did:
   crit.add(KEY2, KEY2 + " is NULL", Criteria.CUSTOM);
that doesn't compile because of ambiguities in parameters.

So, the final thing I did which actually does work is:
   crit.add(KEY2, (Object)(KEY2 + " is NULL"), Criteria.CUSTOM);


That's just silly. Can someone explain to me why Torque can't simply figure 
out what to do when I do:
   crit.add(KEY2,null)
?

Is there a good reason? SQL has many little annoyances (like the lack of an 
"INSERT OR UPDATE" type of statement) which Torque does a good job of 
hiding (all I need to do is call save and it just works). The annoying 
inability to do "KEY2=null" in queries is another stupid sql problem. 
Torque should elevate us above this so that we can add null values in and 
it simply figures out whether to use "IS NULL" or "=someValue".


---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org


Mime
View raw message