Package com.google.code.morphia.utils.LongIdEntity

Examples of com.google.code.morphia.utils.LongIdEntity.StoredId


    public static <T extends Model> Long generateLongId(Class<T> clazz){
        synchronized (clazz) {
            String collName = ds().getCollection(clazz).getName();
            Query<StoredId> q = ds().find(StoredId.class, "_id", collName);
            UpdateOperations<StoredId> uOps = ds().createUpdateOperations(StoredId.class).inc("value");
            StoredId newId = ds().findAndModify(q, uOps);
            if (newId == null) {
                newId = new StoredId(collName);
                ds().save(newId);
            }
            return newId.getValue();
        }
    }
View Full Code Here

TOP

Related Classes of com.google.code.morphia.utils.LongIdEntity.StoredId

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.