Skip to content

Add ability to perform update-with-replace for entire domain object by query [DATAMONGO-198] #1132

@spring-projects-issues

Description

@spring-projects-issues

Sergey Alaev opened DATAMONGO-198 and commented

Currently there is no way to update (overwrite) entire object by query which is very useful for optimistic locking and already provided by mongo java driver. There are two possibilities:

  • Get user a way to create Update from domain object
  • Add new method(s) to MongoOperations like update(Query, Object) - not sure how it will fit into existing update(Query, Update) scheme.

Currently i'm forced to use code like

DBObject object = new BasicDBObject();
mongoTemplate.getConverter().write(project, object);
DBCollection collection = mongoTemplate.getCollection("myCollection");
WriteResult result = collection.update(query, object, WriteConcern.SAFE);

Affects: 1.0 M3

5 votes, 6 watchers

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions