I’m using JPA 2.1 with Hibenrate 5.1.0.Final. How do I write a JPA CriteriaBuilder query in which I’m querying for objects in a date range and I want to include the endpoints of the date range in my query? I’m noticing that the following code
final java.util.Date searchDate = objectDate.toDateTimeAtStartOfDay().toDate();
final ParameterExpression<Date> d = builder.parameter(Date.class);
query.where(
…
builder.between(d, objectRoot.<Date>get(MyObject_.objectDate), objectRoot.<Date>get(MyObject_.objectEndDate)));
This query will not return any results if the criteria falls exactly on one of the endpoints.