List of usage examples for org.springframework.data.mongodb.core MongoActionOperation REMOVE
MongoActionOperation REMOVE
To view the source code for org.springframework.data.mongodb.core MongoActionOperation REMOVE.
Click Source Link
From source file:org.springframework.data.mongodb.core.MongoTemplate.java
protected <T> void doRemove(final String collectionName, final Query query, final Class<T> entityClass) { if (query == null) { throw new InvalidDataAccessApiUsageException("Query passed in to remove can't be null"); }//from www. ja va2s . c om final DBObject queryObject = query.getQueryObject(); final MongoPersistentEntity<?> entity = getPersistentEntity(entityClass); execute(collectionName, new CollectionCallback<Void>() { public Void doInCollection(DBCollection collection) throws MongoException, DataAccessException { DBObject dboq = mapper.getMappedObject(queryObject, entity); WriteResult wr = null; MongoAction mongoAction = new MongoAction(writeConcern, MongoActionOperation.REMOVE, collectionName, entityClass, null, queryObject); WriteConcern writeConcernToUse = prepareWriteConcern(mongoAction); if (LOGGER.isDebugEnabled()) { LOGGER.debug("remove using query: " + dboq + " in collection: " + collection.getName()); } if (writeConcernToUse == null) { wr = collection.remove(dboq); } else { wr = collection.remove(dboq, writeConcernToUse); } handleAnyWriteResultErrors(wr, dboq, "remove"); return null; } }); }