-
Notifications
You must be signed in to change notification settings - Fork 372
Open
Labels
status: feedback-providedFeedback has been providedFeedback has been providedtype: bugA general bugA general bug
Description
The JdbcAggregateTemplate.findAll(Query query, Class domainType, Pageable pageable) accept Pageable, but Query can have it's own limit\offset\sort params set.
When this happens an incorrect SQL is generated.
I think it's worth to at least mention in the javadoc that Query should not have any limit\offset\sort params for this method.
Possible fixes:
- An exception in this case
- Pageable should fully override limit\offset\sort params of the Query
Example:
Criteria criteria = Criteria.where(ParentEntity.COLUMN_ACTIVE).is(true);
Query query = Query.query(criteria)
.offset(1)
.limit(3)
.sort(Sort.by(Sort.Order.desc(ParentEntity.COLUMN_TITLE).nullsFirst()));
Page<ParentEntity> page = operations.findAll(
query, ParentEntity.class,
PageRequest.of(1, 2, Sort.Direction.ASC, ParentEntity.COLUMN_TITLE)
);
generates a query where limit and offset is from Pageable, but sorting includes both criteria
SELECT "parent_entity"."id" AS "id", "parent_entity"."title" AS "title", "parent_entity"."active" AS "active"
FROM "parent_entity"
WHERE "parent_entity"."active" = ?
ORDER BY
"parent_entity"."title" DESC NULLS FIRST,
"parent_entity"."title" ASC
LIMIT 2 OFFSET 2
and COUNT have all criteria from Query including limit and offset and does not work at least in Postgresql
SELECT COUNT(1)
FROM "parent_entity"
WHERE "parent_entity"."active" = ?
ORDER BY "parent_entity"."title" DESC NULLS FIRST
LIMIT 3 OFFSET 1
Metadata
Metadata
Assignees
Labels
status: feedback-providedFeedback has been providedFeedback has been providedtype: bugA general bugA general bug