简体   繁体   中英

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:

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? Or does count() return a value of type 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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