Browse Source

added additional execute signatures

pull/1/head
Thomas Risberg 15 years ago
parent
commit
67fe517379
  1. 17
      src/main/java/org/springframework/datastore/document/mongodb/MongoTemplate.java

17
src/main/java/org/springframework/datastore/document/mongodb/MongoTemplate.java

@ -51,23 +51,22 @@ public class MongoTemplate extends AbstractDocumentStoreTemplate<DB> {
} }
public void execute(String command) { public void execute(String command) {
CommandResult cr = getConnection().command(command); execute((DBObject)JSON.parse(command));
String err = cr.getErrorMessage();
if (err != null) {
throw new InvalidDataAccessApiUsageException("Command execution of " +
command + " failed: " + err);
}
} }
public void execute(DocumentSource<DBObject> command) { public void execute(DocumentSource<DBObject> command) {
CommandResult cr = getConnection().command(command.getDocument()); execute(command.getDocument());
}
public void execute(DBObject command) {
CommandResult cr = getConnection().command(command);
String err = cr.getErrorMessage(); String err = cr.getErrorMessage();
if (err != null) { if (err != null) {
throw new InvalidDataAccessApiUsageException("Command execution of " + throw new InvalidDataAccessApiUsageException("Command execution of " +
command.getDocument().toString() + " failed: " + err); command.toString() + " failed: " + err);
} }
} }
public void createCollection(String collectionName, DocumentSource<DBObject> documentSource) { public void createCollection(String collectionName, DocumentSource<DBObject> documentSource) {
try { try {
getConnection().createCollection(collectionName, documentSource.getDocument()); getConnection().createCollection(collectionName, documentSource.getDocument());

Loading…
Cancel
Save