Wie kann ich ein update-Objekt mit Spring Data und MongoDB?

Wie kann ich ein update-Objekt mit Spring Data und MongoDB?

kann ich einfach eine Vorlage.save()?

  public Person update( String id, String Name ) 
    {
        logger.debug("Retrieving an existing person");
        //Find an entry where pid matches the id

        Query query = new Query(where("pid").is(id));
        //Execute the query and find one matching entry
        Person person = mongoTemplate.findOne("mycollection", query, Person.class);

        person.setName(name);
        /**
        * How do I update the database
        */

        return person;
    }
würdest du bitte akzeptieren Sie die Antwort, die Ihnen geholfen, dieses problem zu lösen, wenn überhaupt?

InformationsquelleAutor user2428795 | 2013-07-03

Schreibe einen Kommentar