GeeCON Prague 2014*
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
Author

[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.
"AdminViewMainAction.java": 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 /> * hashitani@quants.co.jp<br /> * <a href="http://www.quants.co.jp" target="_blank" rel="nofollow">www.quants.co.jp</a><br />*/
Shin Hashitani
Ranch Hand

Joined: Dec 04, 2001
Posts: 54
Update:
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
Well,
magazine.PUBLISHED= IS NOT NULL
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
 
GeeCON Prague 2014
 
subject: [Torque] Criteria.add and NULL value