[JAVA-2525] UpdateFirst with query has sort order not working Created: 29/May/17  Updated: 27/Oct/23  Resolved: 30/May/17

Status: Closed
Project: Java Driver
Component/s: Command Operations
Affects Version/s: 3.4.0
Fix Version/s: None

Type: Task Priority: Major - P3
Reporter: RAJESH GUPTA Assignee: Unassigned
Resolution: Works as Designed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

Hi Team,
I am using Spring Mongo operations and I want to use updateFirst() command. In this method we have to pass the query with criteria. The query has some criterias with Sort Order also but during the updateFirst() it doesn't include the order.



 Comments   
Comment by Jeffrey Yemin [ 30/May/17 ]

Hi Rajesh,

The MongoDB update command does not support specification of a sort criteria, which is why this isn't working in Spring Data MongoDB. To update a single known document you must specify a query filter that identifies the document uniquely.

Alternatively you can use the findAndModify method, which should apply the sort criteria.

Note also that Spring Data MongoDB is a separate project with its own issue tracking system: https://jira.spring.io/browse/DATAMONGO/.

Generated at Thu Feb 08 08:57:26 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.