Hello,
Using ODB 2.4.5 and the Criteria API, doing a simple equals comparison with java.sql.Date value doesn't match any results in the database. Our code looks like this:
CriteriaBuilder builder = ...; Root<MyEntity> root = ...; java.sql.Date myDate = ...; Predicate predicate = builder.equal(root.get("eintritt"), builder.literal(myDate));
Doing exactly the same on the same DB in the DB Explorer via a query string and the same data yields in correctly two results. Calling the toString method of the created predicate yields in something like:
$1.eintritt=2013-11-01
whereas as seen in my manual query string i do something like:
$1.eintritt = {d '2013-11-01'}
Any ideas why this might be the case? Note: We can currently not update the ODB version as this is a production system.
Note also that doing greaterEqual or lessEqual with Criteria API will yield in correct results except if the given date is exactly the same like the value of eintritt field in the DB.
java.sql.Date is used everywhere also in the Entity property field to ensure pure date comparison and saving without time parts so this is made sure.
thanks