I am new to JPA
I am trying to query a table where my input date value should be between the startDate and endDate of the database record
I am trying to do:<
You can try this way.
Predicate date = cb.between(root.get("date"), dateBefore, dateAfter); predicate.add(date);
this way works for my case.
But for your case (using ParameterExpression).
return entityManager.createQuery(query) .setParameter(d, currentDate, TemporalType.DATE).getResultList();
When you create the query you set parameters.
currentDate
is your date,
d
is ParameterExpression
that you create before.
I prefer the first way, it is more intuitive and logical for me.