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 <siber...@gmail.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 >