首页 > 解决方案 > 如何解决这个简单但未解决的 JPA 分页问题?

问题描述

我正在尝试在我的 spring boot 应用程序中使用 native query 和 pagination 进行查询。

 @Query(value = "select * from user pg   ",
     countQuery = "select count(*) from user pg  " ,
    nativeQuery = true)
    Page<User> pesquisar( Pageable page); 

抛出的异常就像Caused by: org.postgresql.util.PSQLException: ERROR: column pg.id does not exist Position: XX.

The Class user , of sure , has the id field . but I try to search about this error and I didn't find then I switch for  order by #{#page} and order codes similar but the error continues, changed but persists with another name.  

更新 :

让我们拿一个用户类样本:

Class User { 
@id
 UUID id ; 

@Column 
String nome; 

etc // 
} 

标签: jpapaginationspring-data-jpapageable

解决方案


推荐阅读