Internal row comparison in ExpressionFactory

From: John Armstrong (siberia..mail.com)
Date: Thu Mar 26 2009 - 12:55:03 EDT

  • Next message: Andrey Razumovsky: "Re: Internal row comparison in ExpressionFactory"

    Hi, I need to do a selection on a table partially based on comparing
    two elements
    of that table. Basically a 'total' and a 'current' where total is a
    changing value and needs to be compared to current to see if the row
    is valid. Its a floating license system for an app I am building.

    This obviously does not work since it expects a numeric, not a string,
    in the value:

    Expression qual = ExpressionFactory.likeIgnoreCaseExp(
                                  com.pgi.License.CODE_PROPERTY,
    licenseCode.trim())
                                  .andExp(
                                                  ExpressionFactory.lessExp(

    com.pgi.License.CLAIMEDUNITS_PROPERTY,

    com.pgi.License.TOTALUNITS_PROPERTY));

    How can I get to to generate SQL like this :

    SELECT t0.license, t0.code, t0.licensetype, t0.product, t0.id,
    t0.validfrom, t0.totalunits, t0.user, t0.validto, t0.datecreated,
    t0.claimedunits FROM license t0 WHERE (UPPER(t0.code) LIKE
    UPPER('7GEN-BTPTDF')) AND (t0.claimedunits < t0.totalunits);

    How would I structure an Expression so that it does an internal
    comparison. I know an SQLTemplate can do it, is this one of those
    times that ExpressionFactory is not really suited to the task?

    J



    This archive was generated by hypermail 2.0.0 : Thu Mar 26 2009 - 12:55:41 EDT