休眠参数值 [568903] 与预期类型 [java.lang.Long] 不匹配
我正在使用Hibernate 4,我在JSF页面中有一个过滤器来获取搜索结果。在执行搜索期间,我收到以下异常
java.lang.IllegalArgumentException: Parameter value [568903] not match expected type [java.lang.Long] at org.hibernate.ejb.AbstractQueryImpl.validateParameterBinding(AbstractQueryImpl.java:370) at org.hibernate.ejb.AbstractQueryImpl.registerParameterBinding(AbstractQueryImpl.java:343) at org.hibernate.ejb.QueryImpl.setParameter(QueryImpl.java:370) at org.hibernate.ejb.QueryImpl.setParameter(QueryImpl.java:323)
以下是我的代码片段,如何解决此问题?
private Long projectNo;
public Long getProjectNo() {
return projectNo;
}
public void setProjectNo(Long projectNo) {
this.projectNo = projectNo;
}
在DAO课程中,我有以下几点
String projectNo = filters.get("projectNo");
List<Predicate> criteria = new ArrayList<Predicate>();
if (projectNo!= null) {
ParameterExpression<String> pexp = cb.parameter(String.class, "projectNo");
Predicate predicate = cb.equal(emp.get(Project_.projectNo), pexp);
criteria.add(predicate);
}
TypedQuery<Project> q = entityManager.createQuery(c);
TypedQuery<Long> countquery = entityManager.createQuery(countQ);
q.setParameter("projectNo", projectNo); // error in this line
countquery.setParameter("projectNo", projectNo);
编辑 1
public void getProjects(ProjectQueryData data) {
在课堂上,我有以下作为构造函数ProjectQueryData
public ProjectQueryData (int start, int end, String field,
QuerySortOrder order, Map<String, String> filters) {