Re: Internal row comparison in ExpressionFactory

From: Andrey Razumovsky (razumovsky.andre..mail.com)
Date: Thu Mar 26 2009 - 15:33:06 EDT

  • Next message: Zissis Trabaris: "Serialization and de-serialization or ROP objects"

    Hi John,

    You should try EJBQL:
    select t0 from License t0 where t0.claimedunits < t0.totalunits AND ....

    http://cayenne.apache.org/doc/ejbqlquery.html

    2009/3/26 John Armstrong <siberia..mail.com>

    > 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 - 15:33:37 EDT