【发布时间】:2016-04-28 15:24:54
【问题描述】:
当我尝试运行此查询时:
Long count = ...;
List<CritereItem> items= new JPAQuery(entityManager).from(foo)
.list( new QCritereItem( foo.id, foo.name, count ));
我得到编译错误,因为构造函数在变量count 处期望NumberPath<Long> 而不是Long,那么如何在querydsl 中选择一个变量?
我将构造函数中的计数替换为:
Expressions.numberTemplate(Long.class, count.toString())
但我得到了这个执行
java.lang.IllegalArgumentException: java.lang.ClassCastException@14edf4
【问题讨论】:
-
请提供
CritereItem的代码