I am using Hibernate 4.0 and I have the following in DAO class for my filter condition
Code:
ParameterExpression<Long> pexp = criteriaBuilder.parameter(Long.class,"empNo");
criteria.add(criteriaBuilder.like(emp.<String>get(String.valueOf(Employee_.empNo)),
String.valueOf(pexp)));
However when I run I am getting the following exception
Code:
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)
How can I fix this issue?
I have tried as
Code:
Predicate predicate = criteriaBuilder.like(emp.get(Employee_.empNo).as(String.class),
pexp.as(String.class));
but the generated sql shows as
Code:
where cast(emp0_.EMP_NO as varchar2(255 char)) like cast(? as varchar2(255 char)