Skip to content

Commit 3dd653a

Browse files
DATAMONGO-1811 - Update documentation of MongoOperations.executeCommand.
Update Javadoc and reference documentation.
1 parent f878474 commit 3dd653a

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoOperations.java

+9-9
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,11 @@ public interface MongoOperations extends FluentMongoOperations {
7272
String getCollectionName(Class<?> entityClass);
7373

7474
/**
75-
* Execute the a MongoDB command expressed as a JSON string. This will call the method JSON.parse that is part of the
76-
* MongoDB driver to convert the JSON string to a Document. Any errors that result from executing this command will be
75+
* Execute the a MongoDB command expressed as a JSON string. Parsing is delegated to {@link Document#parse(String)} to
76+
* obtain the {@link Document} holding the actual command. Any errors that result from executing this command will be
7777
* converted into Spring's DAO exception hierarchy.
7878
*
79-
* @param jsonCommand a MongoDB command expressed as a JSON string.
79+
* @param jsonCommand a MongoDB command expressed as a JSON string. Must not be {@literal null}.
8080
* @return a result object returned by the action.
8181
*/
8282
Document executeCommand(String jsonCommand);
@@ -851,8 +851,8 @@ <T> T findAndModify(Query query, Update update, FindAndModifyOptions options, Cl
851851
* If you object has an "Id' property, it will be set with the generated Id from MongoDB. If your Id property is a
852852
* String then MongoDB ObjectId will be used to populate that string. Otherwise, the conversion from ObjectId to your
853853
* property type will be handled by Spring's BeanWrapper class that leverages Type Conversion API. See
854-
* <a href="http://docs.spring.io/spring/docs/current/spring-framework-reference/core.html#validation" >
855-
* Spring's Type Conversion"</a> for more details.
854+
* <a href="http://docs.spring.io/spring/docs/current/spring-framework-reference/core.html#validation" > Spring's Type
855+
* Conversion"</a> for more details.
856856
* <p/>
857857
* <p/>
858858
* Insert is used to initially store the object into the database. To update an existing object use the save method.
@@ -908,8 +908,8 @@ <T> T findAndModify(Query query, Update update, FindAndModifyOptions options, Cl
908908
* If you object has an "Id' property, it will be set with the generated Id from MongoDB. If your Id property is a
909909
* String then MongoDB ObjectId will be used to populate that string. Otherwise, the conversion from ObjectId to your
910910
* property type will be handled by Spring's BeanWrapper class that leverages Type Conversion API. See
911-
* <a href="http://docs.spring.io/spring/docs/current/spring-framework-reference/core.html#validation" >
912-
* Spring's Type Conversion"</a> for more details.
911+
* <a href="http://docs.spring.io/spring/docs/current/spring-framework-reference/core.html#validation" > Spring's Type
912+
* Conversion"</a> for more details.
913913
*
914914
* @param objectToSave the object to store in the collection. Must not be {@literal null}.
915915
*/
@@ -925,8 +925,8 @@ <T> T findAndModify(Query query, Update update, FindAndModifyOptions options, Cl
925925
* If you object has an "Id' property, it will be set with the generated Id from MongoDB. If your Id property is a
926926
* String then MongoDB ObjectId will be used to populate that string. Otherwise, the conversion from ObjectId to your
927927
* property type will be handled by Spring's BeanWrapper class that leverages Type Conversion API. See <a
928-
* http://docs.spring.io/spring/docs/current/spring-framework-reference/core.html#validation">Spring's
929-
* Type Conversion"</a> for more details.
928+
* http://docs.spring.io/spring/docs/current/spring-framework-reference/core.html#validation">Spring's Type
929+
* Conversion"</a> for more details.
930930
*
931931
* @param objectToSave the object to store in the collection. Must not be {@literal null}.
932932
* @param collectionName name of the collection to store the object in. Must not be {@literal null}.

src/main/asciidoc/reference/mongodb.adoc

+4-3
Original file line numberDiff line numberDiff line change
@@ -2419,13 +2419,14 @@ NOTE: Collection creation allows customization via `CollectionOptions` and suppo
24192419
[[mongo-template.commands]]
24202420
== Executing Commands
24212421

2422-
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.
2422+
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.
24232423

24242424
[[mongo-template.commands.execution]]
24252425
=== Methods for executing commands
24262426

2427-
* `CommandResult` *executeCommand* `(Document command)` Execute a MongoDB command.
2428-
* `CommandResult` *executeCommand* `(String jsonCommand)` Execute the a MongoDB command expressed as a JSON string.
2427+
* `Document` *executeCommand* `(Document command)` Execute a MongoDB command.
2428+
* `Document` *executeCommand* `(Document command, ReadPreference readPreference)` Execute a MongoDB command using the given nullable MongoDB `ReadPreference`.
2429+
* `Document` *executeCommand* `(String jsonCommand)` Execute the a MongoDB command expressed as a JSON string.
24292430

24302431
[[mongodb.mapping-usage.events]]
24312432
== Lifecycle Events

0 commit comments

Comments
 (0)