File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes [Torque] Criteria.add and NULL value Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "[Torque] Criteria.add and NULL value" Watch "[Torque] Criteria.add and NULL value" New topic

[Torque] Criteria.add and NULL value

Shin Hashitani
Ranch Hand

Joined: Dec 04, 2001
Posts: 54
Hi everyone,
NULL is what confuses me. Especially when I deal with them in Torque.
What I thought first was:
Criteria.add(MagazinePeer.PUBLISHED, Criteria.ISNULL);
Well, this doesn't work. I get "Error near 'NULL'" or runtime error of that sort.
In Criteria how to tutorial:
criteria.add(MagazinePeer.PUBLISHED, (Object)"PUBLISH IS NULL", Criteria.CUSTOM);
This is what they suggest. So I trid that. Now the copmile doesn't go through.
"": Error #: 304 : method add is ambiguous. method add(java.lang.String, java.lang.Object, org.apache.torque.util.SqlEnum) class org.apache.torque.util.Criteria and method add(java.lang.String, java.lang.String, java.lang.Object) class org.apache.torque.util.Criteria exists. column 83, Row 12
(**The error message came out in Japanese, so it's my translation)

Removing (Object) casting does let me compile it, but it gives me the runtime error. SqlEnum is a package scoped object, so I cannot cast that, either.
But before that,
this must happen all the time if somebody try to set NULL value to Criteria object.
Do you know how to fix this?
It seems impossible and that can be a huge problem to me.
If you have any idea or suggestion, please let me know. I'd really appreciate it.
Thank you in advance.

/*<br /> * Quants Inc.<br /> * Engineer<br /> *<br /> * Shin Hashitani<br /> *<br /> * <a href="" target="_blank" rel="nofollow"></a><br />*/
Shin Hashitani
Ranch Hand

Joined: Dec 04, 2001
Posts: 54
I checked criteria.toString()
SELECT magazine.MAGAZINE_ID, magazine.SITE, magazine.PUBLISHED, magazine.CREATED, magazine.LAST_MODIFIED, magazine.VISIBLE, magazine.DELETE FROM magazine WHERE magazine.PUBLISHED= IS NOT NULL AND magazine.SITE=10000 ORDER BY magazine.PUBLISHED DESC
this part is definetely wrong, and I think this is what is causing this problem.
So I guess using
add(MagazinePeer.PUBLISHED, Criteria.ISNOTNULL);
does not work. But in that case, why we have Criteria.ISNOTNULL to begin with?
And suggested mathod still gives me compile time error.
I am runnint out of time, and I don't want to leave this part like this. I am still looking for a solution. If you know something, please let me know.
Thank you
I agree. Here's the link:
subject: [Torque] Criteria.add and NULL value
It's not a secret anymore!