I would like to know how the comparsion in the following query will be performed:
StringBuilder queryStr = new StringBuilder();
queryStr.append("SELECT o FROM PRDBook as o WHERE ")
.append("o.publicationDate < :now");
Query query = entityManager.createQuery(queryStr.toString());
Date now = new Date();
query.setParameter("now", now);
In the database, column publicationDate has type timestamp without time zone. Sample value in this column:
2018-03-01 18:00:00
The result of now.toString() is:
Wed Aug 22 16:14:03 CEST 2018
Will the comparsion between mentioned data be performed in that way:
2018-03-01 18:00:00 < 2018-08-22 16:14:03
or that way:
2018-03-01 18:00:00 < 2018-08-22 14:14:03
java.util.Datedoes not have a timezone; it's just an abstract point in time. Have you tried running your code to see what actually happens? So, I vote for the first version being what will happen.