【发布时间】:2018-04-05 08:54:24
【问题描述】:
我已经定义了以下方法来检索匹配提供的标准与分页支持以及按动态列名排序的应用程序。
@Repository
public interface ApplicationsRepository extends JpaRepository<Applications, Long>
@Query(name = "Applications.searchApplication")
Page<Application> search(@Param("roleId")Long userTypeId, @Param("appStatusId")Long appStatusId,
@Param("searchParam") String searchParam, Pageable pageRequest,
@Param("queueType") String queueType);
Here,我发现“Finder 方法 %s 由 NamedQuery 支持” + “并且必须” + "不包含排序参数,因为我们无法修改查询!改用@Query!"
我正在通过以下方式创建 Pageable:
Direction direction = inputDirection == null ? Sort.Direction.DESC : Sort.Direction.ASC;
Sort sort = inputOrderBy == null ? null : new Sort(direction, inputOrderBy);
Pageable pageable =new PageRequest(inPageNo, pagination.inPageSize(), sort);
我担心生成的 Oracle 查询包含“首先获取?仅行”但没有 order by 子句。
在这个问题上的任何帮助都会非常有帮助。
环境:
spring-data-jpa:1.11.4.RELEASE
hibernate-entitymanager:5.0.12.Final
Java 版本:1.8.0_60,供应商:甲骨文公司
操作系统名称:“windows 7”,版本:“6.1”,arch:“amd64”,家族:“dos”
【问题讨论】:
-
我们不能使用查询并根据您从请求中获得的标志添加 order by 子句
-
如果我们必须这样做,您可以分享整个代码,那么也许我们可以考虑解决方案
-
@lab bhattacharjee 您愿意与您的
@Query分享吗?我的意思是Applications.searchApplication
标签: spring hibernate spring-data-jpa