Package de.fhg.igd.mongomvcc

Examples of de.fhg.igd.mongomvcc.VFactory.createDocument()


    // Checkout the "master" branch
    VBranch master = db.checkout(VConstants.MASTER);
   
    // 2. Put something into the index
    VCollection persons = master.getCollection("persons");
    Map<String, Object> elvis = factory.createDocument();
    elvis.put("name", "Elvis");
    elvis.put("age", 3);
    persons.insert(elvis);
   
    // insert another person
View Full Code Here


    elvis.put("name", "Elvis");
    elvis.put("age", 3);
    persons.insert(elvis);
   
    // insert another person
    persons.insert(factory.createDocument("name", "Peter"));
   
    // 3. Commit index to the database
    long firstCid = master.commit();
   
    // 4. Read documents from the database
View Full Code Here

         System.out.print(", age: " + person.get("age"));
      }
      System.out.println(" }");
    }
   
    Map<String, Object> elvis2 = persons.findOne(factory.createDocument("name", "Elvis"));
    if (elvis2 != null) {
      System.out.println("Elvis lives!");
    }
   
    // 5. Make another commit
View Full Code Here

    if (elvis2 != null) {
      System.out.println("Elvis lives!");
    }
   
    // 5. Make another commit
    persons.insert(factory.createDocument("name", "Max"));
    elvis.put("age", 4);
    persons.insert(elvis);
    master.commit();
   
    // 6. Checkout a previous version
View Full Code Here

    persons.insert(elvis);
    master.commit();
   
    // 6. Checkout a previous version
    System.out.println("There are " + persons.find().size() + " persons");
    Map<String, Object> elvis3 = persons.findOne(factory.createDocument("name", "Elvis"));
    System.out.println("Elvis is now " + elvis3.get("age") + " years old");
   
    VBranch oldMaster = db.checkout(firstCid);
    VCollection oldPersons = oldMaster.getCollection("persons");
    System.out.println("Previously, there were only " + oldPersons.find().size() + " persons");
View Full Code Here

    System.out.println("Elvis is now " + elvis3.get("age") + " years old");
   
    VBranch oldMaster = db.checkout(firstCid);
    VCollection oldPersons = oldMaster.getCollection("persons");
    System.out.println("Previously, there were only " + oldPersons.find().size() + " persons");
    Map<String, Object> oldElvis = oldPersons.findOne(factory.createDocument("name", "Elvis"));
    System.out.println("Last year, Elvis was " + oldElvis.get("age") + " years old");
   
    // 7. Drop the database
    db.drop();
  }
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.