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?

Reply via email to