Hi,
I am using an indexed java.util.Date field in my Entity and I came across some weird behaviour in query filters comparing this Date field. Could You please clarify why are there zero-size result collections in the first pack of queries and non-zero size results in the second pack ? I am comparing 2 dates which should be equal because they are showing exactly same inner millisecond count. I attached the whole test case.
public static void main(String[] args) { setUp(); Date date = ClassWithDate.getCorrectDate(new Date()); PersistenceManager pm = getPMF().getPersistenceManager(); // these queries should find 1 item assertQueryResultSize(0, pm.newQuery(ClassWithDate.class, "this.date == datum"), date); assertQueryResultSize(0, pm.newQuery("SELECT FROM ClassWithDate WHERE date == datum PARAMETERS java.util.Date datum" ), date); assertQueryResultSize(1, pm.newQuery(ClassWithDate.class, "this.date.equals(datum)"), date); assertQueryResultSize(1, pm.newQuery(ClassWithDate.class, "this.type.equals(\""+ TYPE +"\") && this.date.equals(datum)"), date); // these queries should find 0 item assertQueryResultSize(0, pm.newQuery(ClassWithDate.class, "this.date < datum"), date); assertQueryResultSize(0, pm.newQuery(ClassWithDate.class, "this.date.before(datum)"), date); assertQueryResultSize(1, pm.newQuery(ClassWithDate.class, "this.date > datum"), date); assertQueryResultSize(1, pm.newQuery(ClassWithDate.class, "this.type.equals(\""+ TYPE + "\") && this.date > datum"), date); assertQueryResultSize(0, pm.newQuery(ClassWithDate.class, "this.date.after(datum)"), date); pm.close(); }