I am trying to using the following code to pull a list of Experience objects from a MySQL
table. Each experience has a from datetime
column and a t
You're just missing the call to CriteriaBuilder.literal():
Date currentDate = new Date();
CriteriaBuilder builder = entityManager.getCriteriaBuilder();
CriteriaQuery query = builder.createQuery(Experience.class);
Root root = query.from(Experience.class);
builder.between(builder.literal(currentDate), root.get("from"), root.get("to"));
return entityManager.createQuery(query).getResultList();