Package com.google.code.morphia

Examples of com.google.code.morphia.Datastore


    private final static ConcurrentMap<String, Datastore> dataStores_ = new ConcurrentHashMap<String, Datastore>();

    public static Datastore ds(String dbName) {
        if (StringUtil.isEmpty(dbName))
            return ds();
        Datastore ds = dataStores_.get(dbName);
        if (null == ds) {
            Datastore ds0 = morphia_.createDatastore(mongo_, dbName);
            ds = dataStores_.putIfAbsent(dbName, ds0);
            if (null == ds) {
                ds = ds0;
            }
        }
View Full Code Here


        Mongo mongo = new Mongo();
        return morphia.createDatastore(mongo, "mydatabase");
    }

    public static void crud() throws Exception {
        Datastore ds = getDatastore();
        // create
        PureMorphiaUser user = new PureMorphiaUser("John", "Smith");
        ds.save(user);
        // read
        PureMorphiaUser user2 = ds.get(PureMorphiaUser.class, user.id);
        // update
        user2.fName = "Tom";
        ds.save(user2);
        // delete
        ds.delete(user2);
    }
View Full Code Here

        // delete
        ds.delete(user2);
    }
   
    public static void query() throws Exception {
        Datastore ds = getDatastore();
        // find
        List<PureMorphiaUser> users = ds.createQuery(PureMorphiaUser.class)
                .filter("fName", "John").filter("lName", "Smith").asList();
    }
View Full Code Here

        return MorphiaPlugin.ds();
    }
   
    public static void deleteDatabase() {
      idCache.clear();
        Datastore ds = ds();
        for (Class<Model> clz: Play.classloader.getAssignableClasses(Model.class)) {
            ds.getCollection(clz).drop();
        }
    }
View Full Code Here

TOP

Related Classes of com.google.code.morphia.Datastore

Copyright © 2018 www.massapicom. 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.