spring 任意选择

inb24sb2  于 2023-01-01  发布在  Spring
关注(0)|答案(1)|浏览(117)
@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);

此方法肯定不会返回ClusterEntity的列表。
你能告诉我当我执行一些任意的查询时返回什么吗?

jgwigjjp

jgwigjjp1#

是的,它肯定不会是ClusterEntity。我不知道你的ClusterEntity的结构,但看起来你试图从你的表中检索多个列,根据你的@Query语句。如果这是真的,那么默认情况下,它返回List<Object[]>,并获得结果转换为一个特定的类型,你可以在这里找到更多的信息,如果没有,那么请更具体。
How to get multiple columns from table using JPA?

相关问题