Browse Source

DATAMONGO-495 - Fixed debug output in MongoTemplate.doFind(…).

Using SerializationUtils to safely output the query to be executed.
pull/9/head
Oliver Gierke 14 years ago
parent
commit
04a17cacb7
  1. 16
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoTemplate.java

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

@ -15,6 +15,7 @@ @@ -15,6 +15,7 @@
*/
package org.springframework.data.mongodb.core;
import static org.springframework.data.mongodb.core.SerializationUtils.*;
import static org.springframework.data.mongodb.core.query.Criteria.*;
import java.io.IOException;
@ -337,7 +338,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware { @@ -337,7 +338,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(String.format("Executing query: %s sort: %s fields: %s in collection: $s",
SerializationUtils.serializeToJsonSafely(queryObject), sortObject, fieldsObject, collectionName));
serializeToJsonSafely(queryObject), sortObject, fieldsObject, collectionName));
}
this.executeQueryInternal(new FindCallback(queryObject, fieldsObject), preparer, dch, collectionName);
@ -1005,8 +1006,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware { @@ -1005,8 +1006,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware {
handleCommandError(commandResult, commandObject);
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(String.format("MapReduce command result = [%s]",
SerializationUtils.serializeToJsonSafely(commandObject)));
LOGGER.debug(String.format("MapReduce command result = [%s]", serializeToJsonSafely(commandObject)));
}
MapReduceOutput mapReduceOutput = new MapReduceOutput(inputCollection, commandObject, commandResult);
@ -1059,8 +1059,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware { @@ -1059,8 +1059,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware {
DBObject commandObject = new BasicDBObject("group", dbo);
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(String.format("Executing Group with DBObject [%s]",
SerializationUtils.serializeToJsonSafely(commandObject)));
LOGGER.debug(String.format("Executing Group with DBObject [%s]", serializeToJsonSafely(commandObject)));
}
CommandResult commandResult = executeCommand(commandObject, getDb().getOptions());
@ -1236,11 +1235,14 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware { @@ -1236,11 +1235,14 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware {
protected <S, T> List<T> doFind(String collectionName, DBObject query, DBObject fields, Class<S> entityClass,
CursorPreparer preparer, DbObjectCallback<T> objectCallback) {
MongoPersistentEntity<?> entity = mappingContext.getPersistentEntity(entityClass);
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("find using query: " + query + " fields: " + fields + " for class: " + entityClass
+ " in collection: " + collectionName);
LOGGER.debug(String.format("find using query: %s fields: %s for class: %s in collection: %s",
serializeToJsonSafely(query), fields, entityClass, collectionName));
}
return executeFindMultiInternal(new FindCallback(mapper.getMappedObject(query, entity), fields), preparer,
objectCallback, collectionName);
}

Loading…
Cancel
Save