Вот моя сущность:
Код: Выделить всё
public class A {
private long id
private String key
private UUID value
}
Код: Выделить всё
@Query(value = """
SELECT key as key,
ARRAY_AGG(value) AS values
FROM table_a
WHERE key IN (:keys)
GROUP BY key
""", nativeQuery = true)
List getValuesByKeys(Collection keys);
Код: Выделить всё
public interface MyProjection {
String getKey();
UUID[] getValues();
}
Код: Выделить всё
Caused by: org.hibernate.query.SemanticException: 'WITHIN GROUP' or 'OVER' clause is mandatory for ordered set aggregate function: array_agg
@Query(value = """
SELECT new MyProjection(key, ARRAY_AGG(a.value))
FROM A a
WHERE a.key IN (:keys)
GROUP BY a.key
""")
List getValuesByKeys(Collection keys);
Заранее спасибо.
Подробнее здесь: https://stackoverflow.com/questions/790 ... spring-jpa