-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Open
Labels
in: infrastructurerelated-to: item-readers-writersstatus: need-help-to-reproduceIssues that we welcome the community to help us reproduceIssues that we welcome the community to help us reproducestatus: waiting-for-reporterIssues for which we are waiting for feedback from the reporterIssues for which we are waiting for feedback from the reportertype: bug
Description
Bug description
When using MongoItemReader with setQuery(Query)
, setSort(Map<String, Sort.Direction>)
, Sort
doesn't works.
If you wanna use setSort()
method, you should use setQuery(String)
method. (If you use MongoItemReaderBuilder
, it might be jsonQuery()
)
Environment
Spring Batch 4.3.5
Steps to reproduce
@Bean
public MongoItemReader<Item> sampleItemReader(MongoTemplate mongoTemplate) {
HashMap<String, Sort.Direction> sorts = new HashMap<>();
sorts.put("_id", Sort.Direction.ASC);
return new MongoItemReaderBuilder<Item>()
.saveState(false)
.template(mongoTemplate)
.collection("items")
.targetType(Item.class)
.pageSize(50)
.query(Query.query(Criteria.where("author").is("minjunkweon")))
.sorts(sorts); // Note: It will doesn't works.
.build();
}
Expected behavior
I think it should work too. But If Spring Data Query
has sorts, I think sorts()
method should be ignored. (use Query's sort definition)
If you never mind it, let me create PR about this?
Minimal Complete Reproducible example
Please see Steps to reproduce
smilejh
Metadata
Metadata
Assignees
Labels
in: infrastructurerelated-to: item-readers-writersstatus: need-help-to-reproduceIssues that we welcome the community to help us reproduceIssues that we welcome the community to help us reproducestatus: waiting-for-reporterIssues for which we are waiting for feedback from the reporterIssues for which we are waiting for feedback from the reportertype: bug