From 37df6efe5f74fb851cb0191418461b4ff9658026 Mon Sep 17 00:00:00 2001 From: Christoph Strobl Date: Tue, 24 Oct 2017 14:49:42 +0200 Subject: [PATCH] DATAMONGO-1811 - Update documentation of MongoOperations.executeCommand. Update Javadoc and reference documentation. --- .../data/mongodb/core/MongoOperations.java | 18 +++++++++--------- src/main/asciidoc/reference/mongodb.adoc | 7 ++++--- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoOperations.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoOperations.java index fa50ab870..0c87ffab8 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoOperations.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoOperations.java @@ -72,11 +72,11 @@ public interface MongoOperations extends FluentMongoOperations { String getCollectionName(Class entityClass); /** - * Execute the a MongoDB command expressed as a JSON string. This will call the method JSON.parse that is part of the - * MongoDB driver to convert the JSON string to a Document. Any errors that result from executing this command will be + * Execute the a MongoDB command expressed as a JSON string. Parsing is delegated to {@link Document#parse(String)} to + * obtain the {@link Document} holding the actual command. Any errors that result from executing this command will be * converted into Spring's DAO exception hierarchy. * - * @param jsonCommand a MongoDB command expressed as a JSON string. + * @param jsonCommand a MongoDB command expressed as a JSON string. Must not be {@literal null}. * @return a result object returned by the action. */ Document executeCommand(String jsonCommand); @@ -851,8 +851,8 @@ public interface MongoOperations extends FluentMongoOperations { * If you object has an "Id' property, it will be set with the generated Id from MongoDB. If your Id property is a * String then MongoDB ObjectId will be used to populate that string. Otherwise, the conversion from ObjectId to your * property type will be handled by Spring's BeanWrapper class that leverages Type Conversion API. See - * - * Spring's Type Conversion" for more details. + * Spring's Type + * Conversion" for more details. *

*

* Insert is used to initially store the object into the database. To update an existing object use the save method. @@ -908,8 +908,8 @@ public interface MongoOperations extends FluentMongoOperations { * If you object has an "Id' property, it will be set with the generated Id from MongoDB. If your Id property is a * String then MongoDB ObjectId will be used to populate that string. Otherwise, the conversion from ObjectId to your * property type will be handled by Spring's BeanWrapper class that leverages Type Conversion API. See - * - * Spring's Type Conversion" for more details. + * Spring's Type + * Conversion" for more details. * * @param objectToSave the object to store in the collection. Must not be {@literal null}. */ @@ -925,8 +925,8 @@ public interface MongoOperations extends FluentMongoOperations { * If you object has an "Id' property, it will be set with the generated Id from MongoDB. If your Id property is a * String then MongoDB ObjectId will be used to populate that string. Otherwise, the conversion from ObjectId to your * property type will be handled by Spring's BeanWrapper class that leverages Type Conversion API. See Spring's - * Type Conversion" for more details. + * http://docs.spring.io/spring/docs/current/spring-framework-reference/core.html#validation">Spring's Type + * Conversion" for more details. * * @param objectToSave the object to store in the collection. Must not be {@literal null}. * @param collectionName name of the collection to store the object in. Must not be {@literal null}. diff --git a/src/main/asciidoc/reference/mongodb.adoc b/src/main/asciidoc/reference/mongodb.adoc index 36fe5ac7e..11c189b60 100644 --- a/src/main/asciidoc/reference/mongodb.adoc +++ b/src/main/asciidoc/reference/mongodb.adoc @@ -2419,13 +2419,14 @@ NOTE: Collection creation allows customization via `CollectionOptions` and suppo [[mongo-template.commands]] == Executing Commands -You can also get at the MongoDB driver's `DB.command( )` method using the `executeCommand(…)` methods on `MongoTemplate`. These will also perform exception translation into Spring's `DataAccessException` hierarchy. +You can also get at the MongoDB driver's `MongoDatabase.runCommand( )` method using the `executeCommand(…)` methods on `MongoTemplate`. These will also perform exception translation into Spring's `DataAccessException` hierarchy. [[mongo-template.commands.execution]] === Methods for executing commands -* `CommandResult` *executeCommand* `(Document command)` Execute a MongoDB command. -* `CommandResult` *executeCommand* `(String jsonCommand)` Execute the a MongoDB command expressed as a JSON string. +* `Document` *executeCommand* `(Document command)` Execute a MongoDB command. +* `Document` *executeCommand* `(Document command, ReadPreference readPreference)` Execute a MongoDB command using the given nullable MongoDB `ReadPreference`. +* `Document` *executeCommand* `(String jsonCommand)` Execute the a MongoDB command expressed as a JSON string. [[mongodb.mapping-usage.events]] == Lifecycle Events