I have defined the following method to retrieve application matching supplied criteria with Pagination support as well as sorting by dynamic column name.
@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, I found "Finder method %s is backed " + "by a NamedQuery and must " + "not contain a sort parameter as we cannot modify the query! Use @Query instead!"
I am creating Pageable in the following way:
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);
My concern is that the generated Oracle Query contains "fetch first ? rows only" but no order by clause.
Any help in this issue will be really helpful.
Environment:
spring-data-jpa:1.11.4.RELEASE
hibernate-entitymanager:5.0.12.Final
Java version: 1.8.0_60, vendor: Oracle Corporation
OS name: "windows 7", version: "6.1", arch: "amd64", family: "dos"
@Query
? I meanApplications.searchApplication
– user3529850