postgresql - 在 hql 中选择新的子查询列表
问题描述
我正在尝试使用属性部分中的子查询。当子查询只返回一个结果时,这很好用。否则显示错误。
[2019-12-30 11:24:26] [21000] 错误:用作表达式的子查询返回的行不止一行
@Query("select new com.example.rest.ShiftResponse(s.id, s.displayTitle, s.startTime, s.endTime, s.max, (select comm from ShiftGroup sg inner join sg.committee comm where sg.shift.id = s.id)) from Shift s where s.event.id = ?1")
这是构造函数的签名
public ShiftResponse(Long id, MultilangText displayTitle, LocalDateTime startTime, LocalDateTime endTime, Integer max, List<Committee> committees) {
除此以外还有什么方法可以指定我希望该参数是一个列表?
解决方案
你检查过这个链接吗?新对象(..)中的 HQL 新列表(..)
在我看来,这是一个类似的问题。它回答了你的问题吗?
推荐阅读
- python - 尝试使用 Matplotlib 在 Python 中绘制动画
- javascript - 如何在 intl-tel-input 中获取 iti__dial-code?
- c# - 无法从 Microsoft 网络聊天机器人框架在浏览器的新选项卡中导航 pdf
- sql - 我不能在 PostgreSQL 中使用十进制转换
- html - Angular:使用引导类“text-white”的 ngClass 无法更改颜色
- python - 如何在python中添加一个按钮
- python - 无法刮取“span”字符串元素beautifulsoup4
- javascript - 包含对象的数组中的浅拷贝与深拷贝
- ios - 不再接受使用 UIWebView 的新应用。相反,使用 WKWebView 来提高安全性和可靠性
- parsing - 针对数据集解析条件字符串