Hi all,
I'm trying to use Pageable in one of my named queries. I'm specifying the page, size, and sort. When the query is executed it looks like pagination is applied but the sort is ignored.
This is running against an HSQLDB database version 2.2.0 and I'm using Spring Data version 1.1.2
My named query is this:
My repository method is defined as:Code:SELECT ae FROM AssetEntity ae JOIN ae.workspace w LEFT JOIN ae.viewPoints v WHERE ae.workspace = :workspace AND ae.name LIKE :name OR v.name LIKE :viewPointName
And the meat of my unit test:Code:@Query(name = AssetEntity.FIND_BY_WORKSPACE_AND_NAME_LIKE_OR_VIEWPOINTS_NAME_LIKE) List<AssetEntity> findByWorkspaceAndNameLikeOrViewPointsNameLike(@Param("workspace") WorkspaceEntity workspace, @Param("name") String name, @Param("viewPointName") String viewPointName, Pageable pageable);
I've removed columns to shorten the query but this is what is being generated:Code:Order order = new Order(Direction.DESC, "name"); PageRequest pageable = new PageRequest(0, 10, new Sort(order)); Collection<AssetEntity> assets = repository.findByWorkspaceAndNameLikeOrViewPointsNameLike(WORKSPACE, filter, filter, pageable);
Just wondering if anyone had any ideas on why the sort wouldn't be applied?Code:SELECT * FROM "RULE" assetentit0_ INNER JOIN "WORKSPACE" workspacee1_ ON assetentit0_."WORKSPACE_ID"=workspacee1_."ID" LEFT OUTER JOIN "RULE_VIEW_POINT" viewpoints2_ ON assetentit0_."ID"=viewpoints2_."RULE_ID" LEFT OUTER JOIN "VIEW_POINT" viewpointe3_ ON viewpoints2_."VIEW_POINT_ID"=viewpointe3_."ID" WHERE assetentit0_."DTYPE"='AssetEntity' AND ( assetentit0_."WORKSPACE_ID"=1000 AND ( assetentit0_."NAME" LIKE 'foo') OR viewpointe3_."NAME" LIKE 'foo') limit 10


Reply With Quote