I have the following in DAO class for my filter condition
ParameterExpression<Long> pexp = criteriaBuilder.parameter(Long.class,"empNo");
criteria.add(criteriaBuilder.equal(emp.get(Employee_.empNo),pexp));
As you can see my empNo is of type Long, how can I use if I would want to use like instead of equal? I tried as
criteria.add(criteriaBuilder.like(emp.<Long>get(Employee_.empNo), pexp)); // gives compilation errors
Edit 1
I have tried the following as well
criteria.add(criteriaBuilder.like(emp.<String>get(Employee_.empNo.toString()),
pexp.toString()));
and this as well
criteria.add(criteriaBuilder.like(emp.<String>get(String.valueOf(Employee_.empNo)),
String.valueOf(pexp)));
However when I run I am getting the following exception
Unable to resolve attribute [org.hibernate.ejb.metamodel.SingularAttributeImpl$Identifier@a21c8
a] against path
java.lang.IllegalArgumentException: Unable to resolve attribute [org.hibernate.ejb.metamodel.Singula
rAttributeImpl$Identifier@a21c8a] against path
at org.hibernate.ejb.criteria.path.AbstractPathImpl.unknownAttribute(AbstractPathImpl.java:116)
at org.hibernate.ejb.criteria.path.AbstractPathImpl.locateAttribute(AbstractPathImpl.java:221)
at org.hibernate.ejb.criteria.path.AbstractPathImpl.get(AbstractPathImpl.java:192)