I am using JAVA JPA Criteria Builder to check a whether a date lies between two dates or not. I am passing the date into the function which is having a query on a table and that table have two dates columns. Now i want to check the date which i have passed lies between the two or not.
private CorpClientsCommRateD getCorpClientsCommRateD(Date date) {
CorpClientsCommRateD commissionRate=null;
try {
CriteriaBuilder builder = em.getCriteriaBuilder();
CriteriaQuery<CorpClientsCommRateD> query = builder.createQuery(CorpClientsCommRateD.class);
Root<CorpClientsCommRateD> root = query.from(CorpClientsCommRateD.class);
List<Predicate> conditions = new ArrayList();
conditions.add(builder.between(date,root.get("effFromDate"),root.get("effToDate")));
query.select(root)
.where(conditions.toArray(new Predicate[]{}));
TypedQuery<CorpClientsCommRateD> commissionRates = em.createQuery(query);
commissionRate=commissionRates.getSingleResult();
}
catch(Exception exp)
{
return commissionRate;
}
return commissionRate;
}
I am getting a error that Error:(148, 35) java: no suitable method found for between(java.util.Date,javax.persistence.criteria.Path,javax.persistence.criteria.Path)
Kindly help