如何使用可分页的Spring数据JPA选择不同的值?

时间:2018-07-12 16:51:12

标签: java sql spring postgresql spring-data-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);

0 个答案:

没有答案