/** * This method does following: * - returns the existing CommandResult if concern is null or less strict than the concern it was obtained with * - otherwise attempts to obtain a CommandResult by calling getLastError with the concern * * @param concern the concern * @return The last error for the concern */ public synchronized CommandResult getLastError(WriteConcern concern) { return writeResult.getLastError(concern); }
/** * calls {@link WriteResult#getLastError(com.mongodb.WriteConcern)} with concern=null * * @return The last error */ public synchronized CommandResult getLastError() { return writeResult.getLastError(); }
/** * This method does following: * - returns the existing CommandResult if concern is null or less strict than the concern it was obtained with * - otherwise attempts to obtain a CommandResult by calling getLastError with the concern * * @param concern the concern * @return The last error for the concern */ public synchronized CommandResult getLastError(WriteConcern concern) { return writeResult.getLastError(concern); }
/** * calls {@link WriteResult#getLastError(com.mongodb.WriteConcern)} with concern=null * * @return The last error */ public synchronized CommandResult getLastError() { return writeResult.getLastError(); }
WriteResult result = collection.insert(list, WriteConcern.FSYNC_SAFE); CommanResult commandResult = result.getLastError(); if (commandResult.get("err") != null) { System.out.println("Alleluyah"); return true; }
/** * @return number of affected documents */ protected int getN() { return wr.getLastError().containsField("n") ? ((Number) wr.getLastError().get("n")).intValue() : 0; }
/** * @return true if updated, false if inserted or none effected */ public boolean getUpdatedExisting() { return wr.getLastError().containsField("updatedExisting") ? (Boolean) wr.getLastError().get("updatedExisting") : false; }
/** * @return true if updated, false if inserted or none effected */ public boolean getUpdatedExisting() { return wr.getLastError().containsField("updatedExisting") ? (Boolean) wr.getLastError().get("updatedExisting") : false; }
/** * @return number of affected documents */ protected int getN() { return wr.getLastError().containsField("n") ? ((Number) wr.getLastError().get("n")).intValue() : 0; }
/** @return true if updated, false if inserted or none effected*/ public boolean getUpdatedExisting() { return wr.getLastError().containsField("updatedExisting") ? (Boolean)wr.getLastError().get("updatedExisting") : false; }
/** @return number of affected documents */ protected int getN() { return wr.getLastError().containsField("n") ? ((Number)wr.getLastError().get("n")).intValue() : 0; }
/** * @return the new _id field if an insert/upsert was performed */ public Object getNewId() { return getInsertedCount() == 1 && wr.getLastError().containsField("upserted") ? wr.getLastError().get("upserted") : null; }
/** * @return the new _id field if an insert/upsert was performed */ public Object getNewId() { return getInsertedCount() == 1 && wr.getLastError().containsField("upserted") ? wr.getLastError().get("upserted") : null; }
@Override public Role removeRole(String roleName) throws MongoException { DBCollection coll = getCollection(); Role role = getRole(roleName); if (role == null) { return null; } WriteResult result = coll.remove(getTemplateObject(role)); if (result.getLastError() != null) { result.getLastError().throwOnError(); } return role; }
protected void throwOnError(final WriteConcern wc, final WriteResult wr) { if (wc == null && wr.getLastConcern() == null) { final CommandResult cr = wr.getLastError(); if (cr != null && cr.getErrorMessage() != null && cr.getErrorMessage().length() != 0) { cr.throwOnError(); } } }
protected void throwOnError(WriteConcern wc, WriteResult wr) { if ( wc == null && wr.getLastConcern() == null) { CommandResult cr = wr.getLastError(); if (cr != null && cr.getErrorMessage() != null && cr.getErrorMessage().length() > 0) cr.throwOnError(); } } public <T> Key<T> save(String kind, T entity) {
@Override public boolean delete(ObjectId id) { DBObject query = new BasicDBObject(); query.put("oid", id.toString()); return collection.remove(query).getLastError().ok(); }
public void delete(DBCollection storage, KvEntity entity) { DBObject query = new BasicDBObject(); query.put("_id", entity.id); query.put("version", entity.version); WriteResult result = storage.remove(query); result.getLastError().throwOnError(); if (result.getN()==0) throw new RuntimeException(); } }
/** * @param wc * @param wr */ protected void throwOnError(WriteConcern wc, WriteResult wr) { if (wc == null && wr.getLastConcern() == null) { CommandResult cr = wr.getLastError(); if (cr != null && cr.getErrorMessage() != null && cr.getErrorMessage().length() > 0) cr.throwOnError(); } }
@Override public boolean put(final RevObject object) { DBObject query = new BasicDBObject(); query.put("oid", object.getId().toString()); DBObject record = toDocument(object); return collection.update(query, record, true, false).getLastError().ok(); }