首页 > 解决方案 > 如何使用可分页的 Spring 数据 JPA 选择不同的值?

问题描述

我想通过分页在我的表中进行不同的选择,但它声称这个错误。有谁知道如何解决它?

org.postgresql.util.PSQLException:错误:对于 SELECT DISTINCT,ORDER BY 表达式必须出现在选择列表中

@Query(value = "SELECT DISTINCT budget.* FROM budget LEFT JOIN user_budget ON budget.id = user_budget.budget_id ORDER BY budget.created DESC, ?#{#pageable}", 
        countQuery = "SELECT DISTINCT count(*) FROM budget LEFT JOIN user_budget ON budget.id = user_budget.budget_id", 
        nativeQuery = true) 
public Page<Budget> findAllByfilter(Pageable pageable);

标签: javasqlspringpostgresqlspring-data-jpa

解决方案


推荐阅读