java - Spring Data JPA 选择不同的列可分页
问题描述
我想根据不为空的列选择不同的记录并返回一个页面。以下是抛出 java.sql.SQLSyntaxErrorException: ORA-01791: not a SELECTed expression。
(如果我能让这个工作,我想通过一些额外的列来选择不同的。)
@Query(value="SELECT DISTINCT pm.batchId from PrintManifest pm",
// + "where pm.batchId is not null"
countQuery = "select count(DISTINCT pm.batchId) from PrintManifest pm",
nativeQuery = true
)
Page<PolicyPrintManifest> findDistinctBatchId(Pageable pageable);
我也试过没有运气:
Page<PolicyPrintManifest> findDistinctByBatchIdExists(Pageable pageable);
执行此查询的正确方法是什么?
解决方案
是表或实体的 PrintManifest 名称。请记住,在本机查询中,您必须使用表名而不是实体名
推荐阅读
- c# - How to use IHostedService in ASP.Net Core?
- dart - Dart 中 void 异步函数的返回类型
- linux - Bash 脚本基本呼吸暂停计时器
- c# - 当授予类型为 ClientCredentialsFlow 时,访问令牌中不包含 MockIdentityServer 客户端声明
- spring - 在 Spring MVC Rest 中获取原始 json 字符串
- laravel - 如何将数据从一个表传输到另一个表
- python - 使用 SMOTE 时 Logistic 回归的输出变化
- swift - 如何创建 TTS 队列?
- newlisp - 在 Newlisp 中读取标准输入到字符串
- powershell - 不进入功能