【问题标题】:JPA select query with multiple values具有多个值的 JPA 选择查询
【发布时间】:2017-01-23 06:01:41
【问题描述】:
select s.id,s.a.id,s.siteName from site  s where s.a.id=:b

我无法执行此语句。

ERROR:
Cannot create TypedQuery for query with more than one return using requested result type [com.a.b.entity.site]

【问题讨论】:

  • 谢谢你。但是我使用了本地查询并且它有效。
  • 我为此使用了本机查询。我按如下方式存储了对象列表..“List obj = Repository.findId(Id);”我试图获取这些值,但它没有工作。 “站点站点; for (Object[] object : obj) { site = new Site(); site.setSiteId(Integer.parseInt(object[0]))); } . 有没有其他方法将对象变为整数

标签: java jpa hql entitymanager


【解决方案1】:

您的子问题的解决方法: 使用这些转换为整数new Integer((int) object[0])

【讨论】:

    猜你喜欢
    • 2017-01-06
    • 2018-05-25
    • 2013-10-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-08-30
    • 2015-05-05
    • 1970-01-01
    相关资源
    最近更新 更多