Browse Source

some more refactoring

pull/1/head
Thomas Risberg 16 years ago
parent
commit
7966aba1e0
  1. 15
      src/main/java/org/springframework/datastore/document/mongodb/MongoTemplate.java

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

@ -58,12 +58,25 @@ public class MongoTemplate extends AbstractDocumentStoreTemplate<DB> {
return connectionFactory; return connectionFactory;
} }
public void execute(String command) {
DB db = getDocumentStoreConnectionFactory().getConnection();
CommandResult cr = db.command(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 = getDocumentStoreConnectionFactory() CommandResult cr = getDocumentStoreConnectionFactory()
.getConnection() .getConnection()
.command(command.getDocument()); .command(command.getDocument());
System.out.println("! " + cr.getErrorMessage()); String err = cr.getErrorMessage();
if (err != null) {
throw new InvalidDataAccessApiUsageException("Command execution of " +
command.getDocument().toString() + " failed: " + err);
}
} }
public void createCollection(String collectionName, DocumentSource<DBObject> documentSource) { public void createCollection(String collectionName, DocumentSource<DBObject> documentSource) {

Loading…
Cancel
Save