You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-user@db.apache.org by Brendan Miller <bm...@dotster.com> on 2007/10/09 19:05:22 UTC

ISNULL with Criterion?

There doesn't seem to be a getNewCriterion(String column, SqlEnum comparison)

What do I do if I need something like

    select ...
     where a < 1 and a > 0 and
      (b is null or (b not like 'abc%' and b not like 'xyz%')

?

I was planning on 

Criteria crit = new Criteria();
crit.add(a, 1, Criteria.LESS_THAN);
crit.add(a, 0, Criteria.GREATER_THAN);
Criterion c1 = crit.getNewCriterion(b, Criteria.ISNULL);  // no such method
Criterion c2 = crit.getNewCriterion(b, (Object) "abc%", Criteria.NOT_LIKE);
Criterion c3 = crit.getNewCriterion(b, (Object) "xyz%", Criteria.NOT_LIKE);
crit.and(c1.or(c2.and(c3)));

This does not work with the ISNULL as part of the criterion.  Is this a 
case where I have to resort to a CUSTOM expression of

    b, (Object) "b is null", Criteria.CUSTOM

?

Thanks,
Brendan

       

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


RE: ISNULL with Criterion?

Posted by Thomas Fischer <fi...@seitenbau.net>.
Just a shot into the dark:

Criterion c1 = crit.getNewCriterion(b, null, Criteria.ISNULL);

does not work ? (probably you have to cast the null)

    Thomas

"Brendan Miller" <bm...@dotster.com> schrieb am 09.10.2007 19:05:22:

>
> There doesn't seem to be a getNewCriterion(String column, SqlEnum
comparison)
>
> What do I do if I need something like
>
>     select ...
>      where a < 1 and a > 0 and
>       (b is null or (b not like 'abc%' and b not like 'xyz%')
>
> ?
>
> I was planning on
>
> Criteria crit = new Criteria();
> crit.add(a, 1, Criteria.LESS_THAN);
> crit.add(a, 0, Criteria.GREATER_THAN);
> Criterion c1 = crit.getNewCriterion(b, Criteria.ISNULL);  // no such
method
> Criterion c2 = crit.getNewCriterion(b, (Object) "abc%",
Criteria.NOT_LIKE);
> Criterion c3 = crit.getNewCriterion(b, (Object) "xyz%",
Criteria.NOT_LIKE);
> crit.and(c1.or(c2.and(c3)));
>
> This does not work with the ISNULL as part of the criterion.  Is this a
> case where I have to resort to a CUSTOM expression of
>
>     b, (Object) "b is null", Criteria.CUSTOM
>
> ?
>
> Thanks,
> Brendan
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> For additional commands, e-mail: torque-user-help@db.apache.org
>


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