0
@Query("select clusters.id, " +
        "sum(greatest(frequencies.january, " +
        "frequencies.february, " +
        "frequencies.march, " +
        "frequencies.april, " +
        "frequencies.may, " +
        "frequencies.june, " +
        "frequencies.july, " +
        "frequencies.august, " +
        "frequencies.september, " +
        "frequencies.october, " +
        "frequencies.november, " +
        "frequencies.december)) summedFrequency " +
        "from ClusterEntity clusters " +
        "left join PhraseEntity phrases on phrases.cluster.id=clusters.id " +
        "left join FrequencyEntity frequencies on frequencies.phrase.id=phrases.id " +
        "where clusters.page.id = :page_id " +
        "group by clusters.id "
)
List<ClusterEntity> findAllClustersByPage(@Param("page_id") Integer pageId);

This method definitely will not return a list of ClusterEntity.

Could you tell what to return when I execute some arbitrary query as in this case.

Kifsif
  • 3,477
  • 10
  • 36
  • 45
  • Does this answer your question? [How to get multiple columns from table using JPA?](https://stackoverflow.com/questions/22653858/how-to-get-multiple-columns-from-table-using-jpa) – Ryednap Dec 31 '22 at 09:00

1 Answers1

0

Yes, It definitely won't be ClusterEntity. I don't know the structure of your ClusterEntity but it seems you are trying to retrieve multiple columns from your table as per your @Query statement. If that's true then by default it returns List<Object[]> and to obtain the result cast it to a specific type, you can find more info here, if not then please be more specific.

How to get multiple columns from table using JPA?

Ryednap
  • 324
  • 1
  • 9