Package com.mongodb

Examples of com.mongodb.WriteResult


        final MongoDbDataContext dataContext = _updateCallback.getDataContext();
        final BasicDBObject query = dataContext.createMongoDbQuery(getTable(), getWhereItems());
       
        WriteConcern writeConcern = _updateCallback.getWriteConcernAdvisor().adviceDeleteQuery(collection, query);
       
        final WriteResult writeResult = collection.remove(query, writeConcern);
        logger.info("Remove returned result: {}", writeResult);
    }
View Full Code Here


        final MongoDbUpdateCallback updateCallback = getUpdateCallback();
        final DBCollection collection = updateCallback.getCollection(getTable().getName());

        final WriteConcern writeConcern = updateCallback.getWriteConcernAdvisor().adviceInsert(collection, doc);

        final WriteResult writeResult = collection.insert(doc, writeConcern);
        logger.info("Insert returned result: {}", writeResult);
    }
View Full Code Here

    public final boolean addUser(final DB db,
            final String username, final String password,
            final boolean readOnly) throws StandardCodedException {
        try {
            if (null != db) {
                final WriteResult result = db.addUser(username,
                        password.toCharArray(), readOnly);
                if (StringUtils.hasText(result.getError())) {
                    throw this.getError500(result.getError());
                }
                return true;
            }
            throw this.getError503("Database cannot be a NULL Object!");
        } catch (Throwable t) {
View Full Code Here

    public final boolean removeUser(final DB db,
            final String username) throws StandardCodedException {
        try {
            if (null != db) {
                final WriteResult result = db.removeUser(username);
                if (StringUtils.hasText(result.getError())) {
                    throw this.getError500(result.getError());
                }
                return true;
            }
            throw this.getError503("Database cannot be a NULL Object!");
        } catch (Throwable t) {
View Full Code Here

        }
    }

    public int remove(final DBObject filter) throws StandardCodedException {
        try {
            final WriteResult result;
            result = _coll.remove(filter);

            if (StringUtils.hasText(result.getError())) {
                throw this.getError418(result.getError());
            }
            return result.getN();
        } catch (Throwable t) {
            throw this.getError500(t);
        }
    }
View Full Code Here

    }

    private boolean update(final DBObject query, final DBObject object,
            final boolean upsert, final boolean multi)
            throws StandardCodedException {
        final WriteResult result = _coll.update(query, object, upsert, multi);
        if (StringUtils.hasText(result.getError())) {
            throw this.getError418(result.getError());
        }
        return this.isUpdatedExisting(result);
    }
View Full Code Here

    }

    private DBObject merge(final DBObject object, final Object id,
            final String[] excludeProperties)
            throws StandardCodedException {
        WriteResult result;
        final DBObject existing = this.findById(id);
        BeeMongoUtils.merge(object, existing, excludeProperties);
        // removeOne empty arrays before save
        final DBObject item = this.removeEmptyArrays(existing);
        // save
        result = _coll.save(item);

        if (StringUtils.hasText(result.getError())) {
            throw this.getError418(result.getError());
        }

        return item;
    }
View Full Code Here

            builder.add("base", state.get("base"));
        }
        builder.add("head", head.toString());
        DBObject nextState = builder.get();

        WriteResult result =
                journals.update(state, nextState, false, false, concern);
        if (result.getN() == 1) {
            state = nextState;
            stateLastUpdated = System.nanoTime();
            return true;
        } else {
            // force refresh when next accessed
View Full Code Here

        long start = start();
        try {
            if (collection == Collection.NODES) {
                nodesCache.invalidate(key);
            }
            WriteResult writeResult = dbCollection.remove(getByKeyQuery(key).get(), WriteConcern.SAFE);
            if (writeResult.getError() != null) {
                throw new MicroKernelException("Remove failed: " + writeResult.getError());
            }
        } finally {
            end(start);
        }
    }
View Full Code Here

        DBCollection dbCollection = getDBCollection(collection);
        long start = start();
        try {
            try {
                WriteResult writeResult = dbCollection.insert(inserts, WriteConcern.SAFE);
                if (writeResult.getError() != null) {
                    return false;
                }
                if (collection == Collection.NODES) {
                    for (Map<String, Object> map : maps) {
                        String id = (String) map.get(UpdateOp.ID);
View Full Code Here

TOP

Related Classes of com.mongodb.WriteResult

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.