Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

[Torque] Criteria.add and NULL value

 
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Shin Hashitani
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic