MongoDB how update element in array using Spring Query Update
<p>In my project I'm using SpringBoot 1.3.2 and org.springframework.data.mongodb.core.query.*</p>

<p>I'm trying to update element in array, in my main object i have array looking like this:</p>

<pre><code>"sections" : [
        {
                "sectionId" : "56cc3c908f5e6c56e677bd2e",
                "name" : "Wellcome"
        },
        {
                "sectionId" : "56cc3cd28f5e6c56e677bd2f",
                "name" : "Hello my friends"
        }
]
</code></pre>

<p>Using Spring I want to update name of record with sectionId 56cc3c908f5e6c56e677bd2e</p>

<p>I was trying to to this like that but it didn't work</p>

<pre><code>  Query query = Query.query(Criteria
                .where("sections")
                .elemMatch(
                        Criteria.where("sectionId").is(editedSection.getId())
                )
        );
        Update update = new Update().set("sections", new BasicDBObject("sectionId", "56cc3c908f5e6c56e677bd2e").append("name","Hi there"));
        mongoTemplate.updateMulti(query, update, Offer.class);
</code></pre>

<p>It create something like:</p>

<pre><code>"sections" : {
         "sectionId" : "56cc3c908f5e6c56e677bd2e",
         "name" : "Hi there"
 }
</code></pre>

<p>But this above is object { } I want an array [ ], and I don't want it remove other elements.</p>

<p>Can any body help me how to update name of record with sectionId 56cc3c908f5e6c56e677bd2e using Spring</p>