cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From John Huss <johnth...@gmail.com>
Subject Re: Weirdnes with Expression's filterObjects results
Date Fri, 01 Jun 2012 14:31:46 GMT
The string 'true' is not the same as the literal value true.  Same for
dates.  You need to pass these objects in object form, not as strings.

On Fri, Jun 1, 2012 at 8:59 AM, Andrew Faust <arjfandy@gmail.com> wrote:

> Good morning everybody.  I am using the following code with (mostly) good
> results:
>
>
> =============================================================
>
> String filterExpr = "*lastName* = 'Simth';
>
> SelectQuery personQuery = new SelectQuery(Person.*class*);
>
> List<Person> fullPersonList = ormContext.performQuery(personQuery);
>
> Expression filterExp = Expression.*fromString*(filterExpr);
>
> List<Person> filteredPersonList = filterExp.filterObjects(fullPersonList);
>
> =============================================================
>
> This works well on any combination of operators such as =, >, <, and so
> on.  This also worrks ok with numeric fields.  So, for string and numeric
> fields this code works ok.
>
>
>
> *HOWEVER*; when I try to filter fields that are booleans or dates then I *
> always* get back an empty results set.  For example...
>
>
>
> Change filterExpr to *filterExpr = "isStaffMember = 'true'"* runs ok but
> returns 0 records which is NOT correct.  Note that if I don't use the '
> character then I get runtime EXCEPTIONS.
>
> Change filterExpr to *filterExpr = "startDate = '2012-02-01'" *again runs
> ok but returns 0 records which is NOT correct.
>
>
>
> Here are some of my runtime particulars:
>
> JDK/JRE: 1.6.0_31
>
> Cayenne version: 3.0.2
>
> DerbyDB version: 10.8.1.2
>
> The database/java fields are: String=VARCHAR/String; numbers are
> integer/Integer; dates are DATE/Date; and booleans are boolean/Boolean.
>
>
>
> In summary, the filterExpFilterObjects(...) seems to work fine IF the
> fields are strings or numbers; but is NOT working as expected with Dates or
> Booleans.  Any ideas anyone?
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message