简体   繁体   English

命名的JPA查询,返回的大小类型错误

[英]Named JPA query with wrong return type of size

I have the following query: 我有以下查询:

select lect from Lecturer lect
where lect.lectures.size > :minNr

and this line from a test fills in the value for minNr: 测试中的这一行填充了minNr的值:

query.setParameter("minNr", 2L);

My Problem is that I always get the following error message: 我的问题是,我总是收到以下错误消息:

java.lang.IllegalArgumentException: Parameter value [2] did not match expected type [java.lang.Integer]

If I change the above test line to 如果我将上述测试行更改为

query.setParameter("minNr", 2);

there is no problem. 没有问题。 But I must not change the test, because it is an assignment. 但是我不能更改测试,因为它是一项任务。

Is there any way to cast the return of size to a Long? 有什么方法可以将大小的返回值转换为Long吗? Or does count() return a value of type Long? 还是count()返回Long类型的值?

Hope you understand my problem. 希望你理解我的问题。

regards 问候

I've used 我用过

Select count(distinct lecture) FROM Lecture join ...

to solve this task. 解决这个任务。 It works fine now. 现在工作正常。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM