当我执行查询时,我会收到堆栈
Caused by: org.hibernate.QueryException: Not all named parameters have been set: [param0] [select count(generatedAlias0.id)
from Position as generatedAlias0 where generatedAlias0.rank=:param0]
执行的方法
public Long CountPosition(Rank aRank, List<Long> Status, List<Long> aStatusInternal) {
QueryBuilder<PozycjaWRankingu> aQuery = queryCountLarge();
aQuery.whereEquals("rank", aRank);
aQuery.whereInNotEmpty("status", Status);
aQuery.whereInNotEmptyAndNotEquals("internal.state", aStatusInternal);
return aQuery.countLarge();
}
最后是查询生成器
public static <T> QueryBuilder<T> createCountLarge(EntityManager aEntityManager, Class<T> aClass) {
QueryBuilder r = new QueryBuilder();
r.em = aEntityManager;
r.criteriaBuilder = r.em.getCriteriaBuilder();
r.criteria = ret.criteriaBuilder.createQuery(Long.class);
r.root = ret.criteria.from(aClass);
r.criteria.select(ret.criteriaBuilder.count(ret.root.get("id")));
return r;
}
知道哪里可能有问题?
编辑 queryCountLarge()返回
QueryBuilder.createCountLarge(em, myClass);