【问题标题】:Named JPA query with wrong return type of size具有错误返回类型大小的命名 JPA 查询
【发布时间】:2015-03-29 21:19:31
【问题描述】:

我有以下疑问:

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

测试中的这一行填充了 minNr 的值:

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

我的问题是我总是收到以下错误消息:

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

如果我把上面的测试线改成

query.setParameter("minNr", 2);

没有问题。但我不能更改测试,因为它是一个作业。

有没有办法将大小的返回值转换为 Long? 还是 count() 返回 Long 类型的值?

希望你能理解我的问题。

问候

【问题讨论】:

    标签: java jpa integer long-integer return-type


    【解决方案1】:

    我用过

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

    来解决这个任务。现在可以正常使用了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-07-02
      • 2020-09-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-04-03
      • 2021-06-09
      相关资源
      最近更新 更多