Package org.springframework.data.mongodb.core

Examples of org.springframework.data.mongodb.core.MongoTemplate.findById()


        new Mongo(), "database"));
    Person p = new Person("Joe", 34);
    // Insert is used to initially store the object into the database.
    mongoOps.insert(p);
    log.info("Insert: " + p); // Find
    p = mongoOps.findById(p.getId(), Person.class);
    log.info("Found: " + p); // Update
    mongoOps.updateFirst(query(where("name").is("Joe")), update("age", 35),
        Person.class);
    p = mongoOps.findOne(query(where("name").is("Joe")), Person.class);
    log.info("Updated: " + p); // Delete mongoOps.remove(p);
View Full Code Here


    mongoOps.insert(p);
    mongoOps.insert(p2);
    log.info("Insert: " + p);
   
    // Find
    p = mongoOps.findById(p.getId(), Person.class);   
    log.info("Found: " + p);
   
    // Update
    mongoOps.updateFirst(query(where("name").is("Joe")), update("age", 35), Person.class);
    //mongoOps.updateMulti(query(where("name").is("Joe")), update("age", 36), Person.class);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.